diff --git a/solutions/05_vecs/vecs2.rs b/solutions/05_vecs/vecs2.rs index 32c1c0f6..87f7625a 100644 --- a/solutions/05_vecs/vecs2.rs +++ b/solutions/05_vecs/vecs2.rs @@ -16,6 +16,11 @@ fn vec_map_example(input: &[i32]) -> Vec { } fn vec_map(input: &[i32]) -> Vec { + // 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() }