Exercise 24

This commit is contained in:
akshitgautam42 2023-11-12 14:25:39 +05:30
parent 55049fd27b
commit 870c4fa864

View File

@ -7,13 +7,13 @@
//
// Execute `rustlings hint vecs2` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
fn vec_loop(mut v: Vec<i32>) -> Vec<i32> {
for element in v.iter_mut() {
// TODO: Fill this up so that each element in the Vec `v` is
// multiplied by 2.
???
*element *=2;
}
// At this point, `v` should be equal to [4, 8, 12, 16, 20].
@ -24,7 +24,7 @@ fn vec_map(v: &Vec<i32>) -> Vec<i32> {
v.iter().map(|element| {
// TODO: Do the same thing as above - but instead of mutating the
// Vec, you can just return the new number!
???
element*2
}).collect()
}