From 6680e6d2023f4b65c7d8dc3d7c140cb188adb271 Mon Sep 17 00:00:00 2001 From: seth <yesifan66@qq.com> Date: Mon, 21 Jun 2021 18:23:05 +0800 Subject: [PATCH] complete: vec --- exercises/collections/vec1.rs | 4 +--- exercises/collections/vec2.rs | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/exercises/collections/vec1.rs b/exercises/collections/vec1.rs index b144fb9..0d4d542 100644 --- a/exercises/collections/vec1.rs +++ b/exercises/collections/vec1.rs @@ -4,11 +4,9 @@ // Make me compile and pass the test! // Execute the command `rustlings hint vec1` if you need hints. -// I AM NOT DONE - fn array_and_vec() -> ([i32; 4], Vec<i32>) { let a = [10, 20, 30, 40]; // a plain array - let v = // TODO: declare your vector here with the macro for vectors + let v: Vec<i32> = vec![10, 20, 30, 40]; (a, v) } diff --git a/exercises/collections/vec2.rs b/exercises/collections/vec2.rs index 6595e40..ed105a8 100644 --- a/exercises/collections/vec2.rs +++ b/exercises/collections/vec2.rs @@ -7,12 +7,9 @@ // Execute the command `rustlings hint vec2` if you need // hints. -// I AM NOT DONE - fn vec_loop(mut v: Vec<i32>) -> Vec<i32> { for i in v.iter_mut() { - // TODO: Fill this up so that each element in the Vec `v` is - // multiplied by 2. + *i*=2 } // At this point, `v` should be equal to [4, 8, 12, 16, 20].