Rust Lifetimes explained Tutorial

preview_player
Показать описание
Let's understand one of the most important core concept of the Rust programming language: Lifetimes

Related Lessons:

0:00 Introduction.
0:50 Preventing Dangling References with Lifetimes. The Borrow Checker
3:45 Generic Lifetimes in functions - First Example
6:18 Lifetimes in functions - Example 2
9:00 Lifetimes Annotations in Structs definitions
9:35 Lifetime Elision
10:55 Three Rules for Lifetimes
11:35 Lifetimes in Methods Definition
12:15 Static Lifetimes
12:45 Last example: Generics Type Parameters, Trait Bounds, Lifetimes together

Рекомендации по теме
Комментарии
Автор

0:00 Introduction.
0:50 Preventing Dangling References with Lifetimes. The Borrow Checker
3:45 Generic Lifetimes in functions - First Example
6:18 Lifetimes in functions - Example 2
9:00 Lifetimes Annotations in Structs definitions
9:35 Lifetime Elision
10:55 Three Rules for Lifetimes
11:35 Lifetimes in Methods Definition
12:15 Static Lifetimes
12:45 Last example: Generics Type Parameters, Trait Bounds, Lifetimes together

francescociulla
Автор

great video hope you can tackle complex lifetimes like multiple lifetimes in struct and methods.

j-p-d-e-v
Автор

9:27 Shouldn't it be the lifetime of the reference we pass into 'a in the ImportantExcerpt struct needs to live at least as long as the struct lives. They are not always the same.

We are allowed to use the first_sentence variable even after the ImportantExcerpt var gets dropped so its lifetime has to be longer.

Basically with lifetimes it's simply "I don't care how long you live if it is at least as long as I am living"

omgky
Автор

One of the most confusing things in Rust (for me)

farzadmf
Автор

I checked out this video hoping it might offer something new.

Content almost identical to Let's Get Rusty with same structure, examples and explanations.


(author responded to my original comment explaining that both tutorials based on the Rust Book which is correct. I'll be kind and give the benefit of the doubt, but this video is surprisingly close. Tried to edit my original comment to be less harsh, but it errored and has now disappeared. Hence this new comment.)

jamesfoxlee