In Rust, I have a Vec
of Vec
. I want to merge the content of one sub Vec
with another one.
Here is my code:
let mut a = vec![vec![1, 2, 3], vec![3, 4, 5, 6], vec![8, 9]];
a[0].append(&mut a[1]);
assert_eq!(&a, &[vec![1, 2, 3, 3, 4, 5, 6], vec![], vec![8, 9]])
The issue is that I cannot borrow twice a
as mutable.
What is the most efficient and idiomatic way to solve it?