Extend vector of Strings (combining two vectors)



examples/vectors/extend-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);

    fruits1.extend(fruits2.clone());
    prt!(fruits1);
    prt!(fruits2);

    prt!(fruits1[3]);
    prt!(fruits2[1]);

    fruits2[1] =
        String::from("some fruit with a very long name that requires more memory than we have");
    prt!(fruits1[3]);
    prt!(fruits2[1]);

    prt!(fruits1);
    prt!(fruits2);
}

 2  2 0x7ffd6a95da18  0x58e4378e9b80 '["apple", "banana"]'
 3  3 0x7ffd6a95de50  0x58e4378e9c00 '["peach", "kiwi", "mango"]'
 5  5 0x7ffd6a95da18  0x58e4378e9d60 '["apple", "banana", "peach", "kiwi", "mango"]'
 3  3 0x7ffd6a95de50  0x58e4378e9c00 '["peach", "kiwi", "mango"]'
 4  4 0x58e4378e9da8  0x58e4378e9d20 '"kiwi"'
 4  4 0x58e4378e9c18  0x58e4378e9c70 '"kiwi"'
 4  4 0x58e4378e9da8  0x58e4378e9d20 '"kiwi"'
71 71 0x58e4378e9c18  0x58e4378e9cb0 '"some fruit with a very long name that requires more memory than we have"'
 5  5 0x7ffd6a95da18  0x58e4378e9d60 '["apple", "banana", "peach", "kiwi", "mango"]'
 3  3 0x7ffd6a95de50  0x58e4378e9c00 '["peach", "some fruit with a very long name that requires more memory than we have", "mango"]'