rust/vec2d/src/lib.rs
changeset 13915 f64790b2a725
parent 13911 fa9f93393e9c
child 13916 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]