Is it even possible to concatenate vectors in Rust? If so, is there an elegant way to do so? I have something like this:
let mut a = vec![1, 2, 3];
let b = v
I can't make it in one line. Damian Dziaduch
It is possible to do it in one line by using chain():
let c: Vec = a.into_iter().chain(b.into_iter()).collect(); // Consumed
let c: Vec<&i32> = a.iter().chain(b.iter()).collect(); // Referenced
let c: Vec = a.iter().cloned().chain(b.iter().cloned()).collect(); // Cloned
let c: Vec = a.iter().copied().chain(b.iter().copied()).collect(); // Copied
There are infinite ways.