diff options
| author | anand <anand.panchdhari@gmail.com> | 2025-11-19 14:35:50 +0530 |
|---|---|---|
| committer | anand <anand.panchdhari@gmail.com> | 2025-11-19 14:35:50 +0530 |
| commit | f8d94cce2a21067d666f65d23d591f0f40cf6c36 (patch) | |
| tree | 773c005674c1b21e3ef68a39feabb87aa2eaa305 /exercises/05_vecs | |
| parent | 8597b29e143cdeae50eafae06e0d8ed900b25295 (diff) | |
Finished vecs and move semantics
Diffstat (limited to 'exercises/05_vecs')
| -rw-r--r-- | exercises/05_vecs/vecs1.rs | 2 | ||||
| -rw-r--r-- | exercises/05_vecs/vecs2.rs | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/exercises/05_vecs/vecs1.rs b/exercises/05_vecs/vecs1.rs index 68e1aff..aa4b64c 100644 --- a/exercises/05_vecs/vecs1.rs +++ b/exercises/05_vecs/vecs1.rs @@ -3,7 +3,7 @@ fn array_and_vec() -> ([i32; 4], Vec<i32>) { // TODO: Create a vector called `v` which contains the exact same elements as in the array `a`. // Use the vector macro. - // let v = ???; + let v = vec![10, 20, 30, 40]; (a, v) } diff --git a/exercises/05_vecs/vecs2.rs b/exercises/05_vecs/vecs2.rs index 0c99626..636f0a7 100644 --- a/exercises/05_vecs/vecs2.rs +++ b/exercises/05_vecs/vecs2.rs @@ -1,9 +1,10 @@ fn vec_loop(input: &[i32]) -> Vec<i32> { let mut output = Vec::new(); - for element in input { + for element in input.iter() { // TODO: Multiply each element in the `input` slice by 2 and push it to // the `output` vector. + output.push(element * 2); } output |
