fixed the variable name to make vecs multiplied by 2

This commit is contained in:
Hariettemaina 2023-05-25 11:03:29 +03:00
parent 8ef0d03cf1
commit d47d23ee86
2 changed files with 3 additions and 3 deletions

View File

@ -18,7 +18,7 @@
// - The output element is going to be a Vector of strings. // - The output element is going to be a Vector of strings.
// Execute `rustlings hint quiz2` or use the `hint` watch subcommand for a hint. // Execute `rustlings hint quiz2` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
pub enum Command { pub enum Command {
Uppercase, Uppercase,

View File

@ -12,7 +12,7 @@ fn vec_loop(mut v: Vec<i32>) -> Vec<i32> {
for element in v.iter_mut() { for element in v.iter_mut() {
// TODO: Fill this up so that each element in the Vec `v` is // TODO: Fill this up so that each element in the Vec `v` is
// multiplied by 2. // multiplied by 2.
*i *= 2; *element *= 2;
} }
// At this point, `v` should be equal to [4, 8, 12, 16, 20]. // At this point, `v` should be equal to [4, 8, 12, 16, 20].
@ -20,7 +20,7 @@ fn vec_loop(mut v: Vec<i32>) -> Vec<i32> {
} }
fn vec_map(v: &Vec<i32>) -> Vec<i32> { fn vec_map(v: &Vec<i32>) -> Vec<i32> {
v.iter().map(|element| { v.iter().map(|&num| {
// TODO: Do the same thing as above - but instead of mutating the // TODO: Do the same thing as above - but instead of mutating the
// Vec, you can just return the new number! // Vec, you can just return the new number!
num * 2 num * 2