equal
deleted
inserted
replaced
31 } |
31 } |
32 } |
32 } |
33 |
33 |
34 impl<T: Copy> Vec2D<T> { |
34 impl<T: Copy> Vec2D<T> { |
35 pub fn new(width: usize, height: usize, value: T) -> Self { |
35 pub fn new(width: usize, height: usize, value: T) -> Self { |
36 let mut vec = Self { |
36 Self { |
37 data: Vec::new(), |
37 data: vec![value; width * height], |
38 width, |
38 width, |
39 height, |
39 height, |
40 }; |
40 } |
41 |
|
42 vec.data.extend(iter::repeat(value).take(width * height)); |
|
43 |
|
44 vec |
|
45 } |
41 } |
46 |
42 |
47 #[inline] |
43 #[inline] |
48 pub fn width(&self) -> usize { |
44 pub fn width(&self) -> usize { |
49 self.width |
45 self.width |