mirror of
https://github.com/notohh/rustlings.git
synced 2024-12-23 19:58:08 -05:00
Add comment to vecs2
This commit is contained in:
parent
835ec72622
commit
6a79ada7f2
1 changed files with 5 additions and 0 deletions
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue