Tour of Rust Table of Contents


A String is a struct that owns a sequence of utf-8 bytes in heap memory.

Because its memory is on the heap, it can be extended, modified, etc. in ways string literals cannot.

Common methods:

When a String is dropped, its heap memory is also dropped.

String has a + operator that extends the string with a &str and returns itself, but it might not be as ergonomic as you hope for.