Memory allocation and freeing up memory is an important part of ownership.
- [Instructor] To illustrate the rules of ownership…we need a data type that is more complex…than the ones we have covered in the previous chapter.…Let's create a new project and call it memory.…And let me CD into the project.…Let's open up the Rust file that Cargo has created…for us and remove the standard code.…So here we'll use the string as the example here…and concentrate on the parts of a string…that relate to ownership.…
These aspects also apply to other complex data types…provided by the standard library and that you create.…Let's create a string, S.…Let mute S equals string,…which is a key word here, and double colon.…The double colon is an operator that allows us to namespace…this particular from function under the string type.…And then we say from, and then parse…the string that we want here.…
This type is allocated on the heap and as such…is able to store an amount of text that…is unknown to us at compile time.…This kind of string can be mutated…using the function push_str.…Let's do that.…Let's add "world" to this string "hello,"…
- Installing Rust
- Data types
- Adjusting memory allocation
- Setting up race conditions
- Working with functions
- Exploring references and borrowing
- Using structs
- Method syntax
- Demonstrating recoverable errors with Result
- Working with enums
- Getting user input
Skill Level Beginner
1. Hello, Rust!
2. Basic Programming Concepts
3. Ownership in Rust
4. Data Handling and Pattern Matching in Rust
5. Error Handling
6. Sample Rust Project: The Guessing Game
Next steps1m 14s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.