- append
Append vector of Strings (moving over elements)
- This will empty the second vector.
examples/vectors/append-strings/src/main.rs
macro_rules! prt { ($var:expr) => { println!( "{:2} {:2} {:p} {:15?} '{:?}'", $var.len(), $var.capacity(), &$var, $var.as_ptr(), $var ); }; } fn main() { let mut fruits1 = vec![String::from("apple"), String::from("banana")]; prt!(fruits1); let mut fruits2 = vec![String::from("peach"), String::from("kiwi"), String::from("mango")]; prt!(fruits2); prt!(fruits2[1]); fruits1.append(&mut fruits2); prt!(fruits1[3]); prt!(fruits1); prt!(fruits2); }
2 2 0x7ffcda3de400 0x5aae5be7fb80 '["apple", "banana"]' 3 3 0x7ffcda3de838 0x5aae5be7fc00 '["peach", "kiwi", "mango"]' 4 4 0x5aae5be7fc18 0x5aae5be7fc70 '"kiwi"' 4 4 0x5aae5be7fcf8 0x5aae5be7fc70 '"kiwi"' 5 5 0x7ffcda3de400 0x5aae5be7fcb0 '["apple", "banana", "peach", "kiwi", "mango"]' 0 3 0x7ffcda3de838 0x5aae5be7fc00 '[]'