I have two slice or vectors and I want to add them, as demonstrated here in Golang:
a := []byte{1, 2, 3}
b := []byte{4, 5, 6}
ab := append(a, b...)
ba := append(b, a...)
How can I do that in Rust? I found some other questions, such as:
but, all of their best answer is a += b
, and not ab = a + b
.
let mut a = vec![1, 2, 3];
let mut b = vec![4, 5, 6];
a.append(&mut b);
assert_eq!(a, [1, 2, 3, 4, 5, 6]);
assert_eq!(b, []);
Or is there maybe a function like Vec::append(a, b)
in Rust?