home ~ socials ~ projects ~ rss

Append One Vec To Another Vec In Rust

July 2023

From the docs

let mut vec = vec![1, 2, 3];
let mut vec2 = vec![4, 5, 6];

vec.append(&mut vec2);

assert_eq!(vec, [1, 2, 3, 4, 5, 6]);
assert_eq!(vec2, []);
end of line
Share link:
https://www.alanwsmith.com/en/2s/lw/5s/d8/?append-one-vec-to-another-vec-in-rust