diff options
| author | mo8it <mo8it@proton.me> | 2024-06-21 15:06:50 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-06-21 15:06:50 +0200 |
| commit | 6a79ada7f2afc668418c8fd15e2db622f3d833af (patch) | |
| tree | 4957d964da50c6827e607c6e99de19d0da081c3f /solutions/05_vecs/vecs2.rs | |
| parent | 835ec7262247a341295c1d6f3772901a5fad5148 (diff) | |
Add comment to vecs2
Diffstat (limited to 'solutions/05_vecs/vecs2.rs')
| -rw-r--r-- | solutions/05_vecs/vecs2.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/solutions/05_vecs/vecs2.rs b/solutions/05_vecs/vecs2.rs index 32c1c0f..87f7625 100644 --- a/solutions/05_vecs/vecs2.rs +++ b/solutions/05_vecs/vecs2.rs @@ -16,6 +16,11 @@ fn vec_map_example(input: &[i32]) -> Vec<i32> { } fn vec_map(input: &[i32]) -> Vec<i32> { + // We will dive deeper into iterators, but for now, this is all what you + // had to do! + // Advanced note: This method is more efficient because it automatically + // preallocates enough capacity. This can be done manually in `vec_loop` + // using `Vec::with_capacity(input.len())` instead of `Vec::new()`. input.iter().map(|element| 2 * element).collect() } |
