From 391e22e5e8217fdd0cbc16db545f31629901f931 Mon Sep 17 00:00:00 2001 From: Pratik Sharma Date: Sun, 19 Mar 2023 17:36:35 +0530 Subject: [PATCH] new change --- exercises/vecs/vecs2.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/exercises/vecs/vecs2.rs b/exercises/vecs/vecs2.rs index 5bea09a2..aed62be7 100644 --- a/exercises/vecs/vecs2.rs +++ b/exercises/vecs/vecs2.rs @@ -6,13 +6,13 @@ // // Execute `rustlings hint vecs2` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE +// I AM NOT fn vec_loop(mut v: Vec) -> Vec { for i in v.iter_mut() { // TODO: Fill this up so that each element in the Vec `v` is // multiplied by 2. - ??? + *i = *i * 2 } // At this point, `v` should be equal to [4, 8, 12, 16, 20]. @@ -20,11 +20,13 @@ fn vec_loop(mut v: Vec) -> Vec { } fn vec_map(v: &Vec) -> Vec { - v.iter().map(|num| { - // TODO: Do the same thing as above - but instead of mutating the - // Vec, you can just return the new number! - ??? - }).collect() + v.iter() + .map(|num| { + // TODO: Do the same thing as above - but instead of mutating the + // Vec, you can just return the new number! + num * 2 + }) + .collect() } #[cfg(test)]