Strings

Typically, a string can be defined in one of two ways:

let myName = "my name"; 

This is known as a string slice. These will be dealt with in a while.

The second way is to use String::new();. This is a String, with a capital S. It is allocated in the heap and can grow dynamically.

At this point, it would be a good idea to break with the current narrative and discuss how Rust uses memory, as it will help greatly with explaining a number of upcoming topics.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset