Capacity of string



examples/strings/capacity/src/main.rs
macro_rules! prt {
    ($var:expr) => {
        println!("{:2} {:2} {:?}", $var.len(), $var.capacity(), $var,);
    };
}

fn main() {
    let mut text = String::new();
    prt!(text);

    text.push('A');
    prt!(text);

    text.push_str(" black ");
    prt!(text);

    text.push_str("cat");
    prt!(text);

    text.push_str(" climebed");
    prt!(text);
}

 0  0 ""
 1  8 "A"
 8  8 "A black "
11 16 "A black cat"
20 32 "A black cat climebed"