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: Basics of vectors - Rust Tutorial
From the course: Rust Programming: From Fundamentals to Advanced Concepts with AI-Assisted Development
Demo: Basics of vectors
- [Instructor] Vectors and slices in Rust are, have like a similar relationship as strings and string slices, just like we've seen before. Now let's take a look at some of the differences. So here we have a main function and I would say like one of the main things is that slices, you should see them as almost like fixed in size and they're immutable, not always though so it's, I'm hesitant to say that that's like a mandatory or exclusive thing, but if you think about something that is not growable or that the size can be unknown, then vectors are your, the go-to data structure that you want to use. Otherwise, slices are fine. So let's start with ownership. And I'm going to comment this album, modifiable is going to be comment out and we'll take a look at that in a second. So let's run ownership and let's see what is going on. So we're going to get a sample slice and one, two, and three and let's take a look at what we have here. So first we define the vector. The vector will have…
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)
-
-
-
-
-