Part of the Rust Crash Course: https://www.youtube.com/playlist?list=PL6yRaaP0WPkWRsXJgdnw9lj1vchAaKwfS
Welcome to the Rust Crash Course
In this course, we will be learning Rust from scratch. This course is very fast paced and designed for programmers who already have some experience with another programming language such as Dart or JavaScript or Swift. We will talk about variables, constants, ownership, functions, structures, enumerations, collections such as tuples, vectors, hash-maps and iterators, optionals, error handling, lifetime specifiers, traits, pointers, generics, packages, crates, modules and paths, asynchronous programming and we will also create 2 sample applications using Rust to put all these concepts to use!
Rust manages the lifetime of variables very diligently and it needs our help in doing so. In this chapter we will look at the rules that govern the lifetime of variables and when they get allocated and dropped in Rust.
Timestamps:
00:00 - Lifetimes
01:04 - Sample function that won't compile
04:08 - Tell Rust how long &str lives
05:27 - Generic lifetime annotations
09:09 - Missing lifetime annotations in structs
10:51 - Specify lifetime annotations in structs
11:04 - Lifetime elision
12:41 - Lifetime rules
12:50 - Lifetime rule #1
13:34 - Lifetime rule #2
14:38 - Lifetime rule #3
15:30 - Define a Person
16:08 - Create implementation for Person
16:49 - Define function for Person
17:25 - Return first character of first name
18:40 - Return full name (can't use &str)
19:33 - Lifetime in enums
20:29 - Lifetimes are fundamental to how Rust manages memory
If you want to support my work, please consider joining my YouTube channel by pressing the Join button!
Twitter: https://twitter.com/vandadnp
LinkedIn: https://linkedin.com/in/vandadnp
Let's get started!