When a data value might change size, it pretty much has to be stored on the heap. For this reason, the Rust prelude includes the String and Vec types, which are smart pointers specialized for storing text and variable-length arrays, respectively.
Vec and String
String
We've already seen String several times, when we used it to simplify the ownership of text strings. There are other things we can do with it, though, because the text stored in a String can be changed.
Here, we're changing a String several times, as shown in the following code:
let mut text = String::new();
text.push('W');
text.push_str("elcome to mutable strings");
text.insert_str(11, "exciting ");
text.replace_range(28.....