-
I think there's a one line solution. I have checked the Iterator / Vec documentation, but can not find which function to use.
-
I have the following:
pub fn foo() {
let input = vec![1_i32, 2, 3];
let output = vec![1_i32, 2, 4];
let t: Vec<i32> = input.iter().map(|x| x + 1).collect();
}
- What happens here is that the mapped results are dumped into a new vector t ... what I want is for the iterator results to be appended to the end of "output". Is there a way to "collect into an existing vector"?