Rust TutorialLesson 19Free preview
Rust Strings
This lesson is part of Rust · All levels
Summary
This lesson peels out the text representation in Rust which is divided into string slice (&str) and heap-owned String. Rust requires all UTF-8-formatted strings to be valid to prevent international text encoding errors. The developer will learn text manipulation, connectivity, and conversion between string types.
Key points
- The '&str' type is a string slice that usually refers to fixed text that is immutable
- The 'String' type is allocated in heaps, can be lengthened, and is mutable if 'mut' is used.
- All strings in Rust are guaranteed to be valid UTF-8 internally.
- Strings can be created from the literal using the 'String::from()' or '.to_string() ' methods.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.