From the course: Rust Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

String data type

String data type - Rust Tutorial

From the course: Rust Essential Training

Start my 1-month free trial

String data type

- [Instructor] All of the data types we've used so far in this course from integers to tuples all have a fixed size that's known to the compiler, which means they'll be stored on the stack. Before we can continue forward to explore Rust's key concept of ownership, we'll need to learn about a new data type that gets stored on the heap, the string. Now, there are two ways to work with a string or sequence of characters in Rust. We've already seen one type of string written out and enclosed in double quotes. This is called a string literal because it's literally written in the code. The compiler will hard-code that sequence of characters into the executable file, and when the program runs, it gets loaded into memory. When the program needs to use the literal value, it will access it through a reference and we'll cover that in a bit more detail later in this course. String literals are certainly handy and we've used them…

Contents