From the course: Rust Programming: From Fundamentals to Advanced Concepts with AI-Assisted Development
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Demo: Understanding string and str - Rust Tutorial
From the course: Rust Programming: From Fundamentals to Advanced Concepts with AI-Assisted Development
Demo: Understanding string and str
- [Instructor] Let's see some of the differences between string and string slices in Rust. We have a string slice, which is this thing right here, which is STR. Almost always you'll see with an ampersand, which means it's almost always going to be a pointer to, a reference to some existing piece of data that is owned by someone else. The difference, one of the difference, many differences between that and string is that you cannot mute, you cannot mutate, you cannot change, you cannot modify STR or the string slice. Sometimes Rust programmers will call this a string, and this thing a string as well. But most commonly is most correct to say this is a string slice, and this is a string type. Let's start playing around with a little bit of the differences that we have here, and we are creating a string slice here. Let's take a look at what we have here. When we say, when we ask Visual Studio Code to tell us what are the types. So you'll see here that this is SDR, and that's effectively…
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Introduction to strings and vectors1m 16s
-
(Locked)
Demo: Understanding string and str5m 16s
-
(Locked)
Demo: Getting started with Rust string manipulation6m 25s
-
(Locked)
Demo: Basics of vectors6m 42s
-
(Locked)
Demo: Retrieving values from vectors7m 52s
-
(Locked)
Demo: Adding elements to vectors3m 43s
-
(Locked)
Summary of strings and vectors1m 20s
-
(Locked)
-
-
-
-
-