author | unc0rr |
Sun, 14 Oct 2018 21:26:15 +0200 | |
changeset 13920 | f64790b2a725 |
parent 13919 | ef50e4f59b8f |
child 13921 | cd437d76978a |
--- a/rust/vec2d/src/lib.rs Sun Oct 14 23:25:20 2018 +0300 +++ b/rust/vec2d/src/lib.rs Sun Oct 14 21:26:15 2018 +0200 @@ -33,15 +33,11 @@ impl<T: Copy> Vec2D<T> { pub fn new(width: usize, height: usize, value: T) -> Self { - let mut vec = Self { - data: Vec::new(), + Self { + data: vec![value; width * height], width, height, - }; - - vec.data.extend(iter::repeat(value).take(width * height)); - - vec + } } #[inline]