Understanding Ownership in Rust

  Рет қаралды 231,092

Let's Get Rusty

Let's Get Rusty

Күн бұрын

The ultimate Rust lang tutorial. Follow along as we go through the Rust lang book chapter by chapter.
📝 Get your FREE Rust Cheatsheet: www.letsgetrusty.com/cheatsheet
The Rust book: doc.rust-lang.org/stable/book/​
Stack & Heap explanation: • Pointers and dynamic m...
0:00 Intro
0:40 Ownership Model
4:30 Stack & Heap
6:53 Ownership Rules
7:21 Variable Scope
8:22 Memory & Allocation
10:32 Ownership & Functions
12:23 References & Borrowing
18:34 The Slice Type
24:56 Outro
#letsgetrusty​ #rust​lang #tutorial

Пікірлер: 287
@letsgetrusty
@letsgetrusty 2 жыл бұрын
📝Get your *FREE Rust Cheatsheet* : www.letsgetrusty.com/cheatsheet
@enderger5308
@enderger5308 3 жыл бұрын
I don’t know why, but the borrow checker doesn’t confuse me that much. Use a reference when you want to see the original memory through a window, move when you want the data for yourself, and never have a window to a place that does not exist.
@letsgetrusty
@letsgetrusty 3 жыл бұрын
You are one of the chosen.
@ddastoor
@ddastoor 3 жыл бұрын
a good example from soft engg is to compare the ownership model with read-write lock semantics...
@inx1819
@inx1819 3 жыл бұрын
The basics of borrow checking isn't hard, but sometimes it can get tricky and very confusing in complicated code
@comradedownpressor1218
@comradedownpressor1218 2 жыл бұрын
This is the best concise explanation of borrowing I've seen yet
@OggerFN
@OggerFN 2 жыл бұрын
@@ddastoor because it's about the same problem
@eileennoonan771
@eileennoonan771 4 ай бұрын
I am going to watch this every day until I understand it in my bones
@tullochgorum6323
@tullochgorum6323 2 жыл бұрын
As a line-of-business developer I've been a bit intimidated about learning an innovative system language like Rust - but this makes one of the gnarliest features seem learnable. You're a good teacher.
@stardustbiscuits
@stardustbiscuits 2 жыл бұрын
Wait until u learn traits
@nathanielwoodbury2692
@nathanielwoodbury2692 3 жыл бұрын
You're an incredible teacher, so much clarity.
@islapthebass
@islapthebass 2 жыл бұрын
He doesn't derail ever, seamless additive commentary, and an enjoyable voice haha
@carloslfu
@carloslfu 2 жыл бұрын
+1
@kayakMike1000
@kayakMike1000 Жыл бұрын
Most of what he said about stacks and heaps was misleading enough that I don't think he really understands it very well.
@-karter-4556
@-karter-4556 9 ай бұрын
Basically just summarizing the book
@playfulyogi5639
@playfulyogi5639 8 ай бұрын
@@-karter-4556 almost word for word plagiarism
@desrucca
@desrucca 2 жыл бұрын
Finally, found someone that covers the rust guide book. Thanks, man. Super time saver
@letsgetrusty
@letsgetrusty 2 жыл бұрын
Glad I could help!
@jesusmtz29
@jesusmtz29 Жыл бұрын
im amazed at how much the rust-analyzer and compiler are teaching me without even running code. You're explanation makes it a top-grade experience
@giovannimazzocco499
@giovannimazzocco499 2 жыл бұрын
This is by far the best explanation about Rust's borrow mechanism I've encountered so far! The course is an excellent resource for Rust newcomers. Great work!
@danielhalachev4714
@danielhalachev4714 2 ай бұрын
It was *borrowed* from the book.
@scheimong
@scheimong 2 жыл бұрын
Wish I had this video last year when I was learning Rust. You explained the concepts fantastically.
@bobbybob628
@bobbybob628 2 жыл бұрын
The very best channel for Rust learners that I have found so far! Thank you, buddy! Wish you all the best and prosperity to your channel!
@agustindeluca2304
@agustindeluca2304 2 жыл бұрын
Mindblowing 🤯🤯🤯 Thank you so much for your dedication. You're an incredible teacher!
@SKyrim190
@SKyrim190 2 жыл бұрын
I think that was the best explanation I've come across so far...you took the time a noobie would need to learn this stuff, and didn't try to "keep under two minutes" destroying the clarity for the sake of speed. Also, you didn't jump immediately to metaphors of "oh, its like if you have a book, and you lend it to someone, but that person can write on the book" and so on...I also find those unnecessary and confusing sometimes
@eslamelsharkawy9660
@eslamelsharkawy9660 Жыл бұрын
I think this is the best video on KZfaq to explain the ownership model. Great Work.
@biocuts
@biocuts 2 жыл бұрын
You explained it in a very concise and clear way. Good job!
@yichizhang5707
@yichizhang5707 3 жыл бұрын
I read the rust book ownership chapter but was confused. Your video makes the concept much clearer. Thanks and keep it up!
@martynclarke8400
@martynclarke8400 Жыл бұрын
Honestly man, your videos have really helped me whilst I go through the book. Theres a lot of information to consume so appreciate you taking the time to make these accompanying videos (y), some things are easier to see than to read and vice versa :)
@Antonio-ix3fw
@Antonio-ix3fw Жыл бұрын
I have just started learning Rust and your videos are helping me to understand all the tricky Rust concepts. Thanks! .
@bigtymer4862
@bigtymer4862 2 жыл бұрын
Going through the rust book right now... very helpful!
@MCGreen13
@MCGreen13 Жыл бұрын
This was the best outline of this topic that I’ve seen. Thank you.
@samdavepollard
@samdavepollard Жыл бұрын
Very nice series As a hobbyist who's dabbled in a bunch of languages because it's fun, i'm now learning me some rust. Certainly doing my share of fighting with the borrow checker but that said, i'm super impressed with the errors and warnings that the compiler spits out. Most helpful messages that i've encountered in any language; have helped me sort out a bunch of things which in other languages i would have had to fire up the google to work out what was going on.
@exoticcoder5365
@exoticcoder5365 3 жыл бұрын
good work ! I understand a lot ! can't wait to see more Rust content !
@TheOriginalJohnDoe
@TheOriginalJohnDoe 2 жыл бұрын
You sir... are an incredible teacher and have just got a new subscriber!
@sukarnarut
@sukarnarut Жыл бұрын
Awesome teaching. The pace is very good and information goes straight into my brain with good understanding of the concept.
@TheSkepticSkwerl
@TheSkepticSkwerl Жыл бұрын
i took an online course, it was short but still, it explained Strings and string slices. (literals) etc... but the way you explained them in this video were so much more clear. thank you.
@user-qr4jf4tv2x
@user-qr4jf4tv2x 9 ай бұрын
the reference and borrow is definingly the best part of this tutorial
@aaronkingcto
@aaronkingcto Жыл бұрын
This is really fantastic! Your cadence, examples and explanations are really great! I've been programming for 25 years (C++, C#, Js, etc etc) and this is a really nice way to understand nuances of rust. Thank you!
@kayakMike1000
@kayakMike1000 Жыл бұрын
25 years and this rank amateur explains things well? What? Are you one of those php script monkeys? It was awful.
@kmaximoff
@kmaximoff Ай бұрын
I was worried learning Rust, but more I look at this. THIS MAKES SO MUCH SENSE!
@adamtak3128
@adamtak3128 2 жыл бұрын
Really good video. I'll be coming back to this over and over until it's stuck in my memory.
@abdullahfurkanozbek7558
@abdullahfurkanozbek7558 Жыл бұрын
Perfect explanation, even though the concept is hard to understand, the explanations and examples provided in this video are very valuable. Thank you for it.
@opticonor
@opticonor Жыл бұрын
Great vid, looking forward to watching the rest of them!
@TheKisem
@TheKisem 10 ай бұрын
First tutorial series on KZfaq where I don't even hesitate for a second before clicking the thumbs up button. Great job!
@garotalibertaria7219
@garotalibertaria7219 10 ай бұрын
Best explanation about ownership and borrowing, it helped me a lot.
@rishkum536
@rishkum536 2 жыл бұрын
Beautiful video bro. Thanks for creating this. I understand what is so special about Rust now
@Tobi-gl2lb
@Tobi-gl2lb Жыл бұрын
Thanks a lot for this series. Very good explained.
@AndrewLighten
@AndrewLighten Ай бұрын
Brilliant explanation. Thank you.
@sahilverma4077
@sahilverma4077 3 жыл бұрын
awsome explanation, keep up the good work
@muthuisheree
@muthuisheree Жыл бұрын
Thank you for the wonderful explanation. Extremely valuable
@Souljacker7
@Souljacker7 Жыл бұрын
I was struggling understanding Steve Klabnik's and Carol Nichols' book, but you made it perfectly clear. Thanks!
@-karter-4556
@-karter-4556 9 ай бұрын
I wish I found this language sooner 😫. The control and defined, predictable behavior is so appealing.
@ViniciusKrolow
@ViniciusKrolow Жыл бұрын
what a great explanation I was so confused now that I decided to learn the language and you made it all clear for me in 25min YOU ROCKS! thx from 🇧🇷
@dixztube
@dixztube 8 ай бұрын
I work with node and go for my serious business projects but I did get a offer from a firm that uses rust and pretty flexible timeline if I ever wanted to onboard. This got me into going through the rust book and learning the language… I really like it! I also liked go a lot too.. probably because I started in insane crazy js land now these relatively new languages seem to nice
@alfredomenezes8814
@alfredomenezes8814 Жыл бұрын
This lesson was amazing, thank you very much 🦀❤️
@twentyeightO1
@twentyeightO1 Жыл бұрын
Man I'm getting all worked up converting my c++ program to rust. 2 days in and I am no where near to finish it. Now I've realized that my "c++ way of thinking" is getting in the way.
@ostap418
@ostap418 2 жыл бұрын
Thank you so much, I am learning rust after java and javascript background, and it's quit tough. But your videos help a lot! Thank you
@WarrenMarshallBiz
@WarrenMarshallBiz Жыл бұрын
This channel is pure gold, thanks man!
@Haitaish
@Haitaish Жыл бұрын
10:53 "When we pass in parameters into a function its the same as if we were to assign s into another variable" - now that's when the borrow checker finally clicked for me. Now I also understand why it's so controversial to some people. Your tutorial so clear and easy to understand. Thank you!
@MrSerler
@MrSerler Жыл бұрын
thank you so much. great tutorial.
@almuaz
@almuaz 5 ай бұрын
I read the book and i was overwhelmed of new terms and information. this video helped me to visualize it live. yes rust book visualizations were great but for me i find this more helpful. i think after watching this, i will understand the book better. thank you. there are too little learning resources for rust :)
@connorzittrauer3306
@connorzittrauer3306 Жыл бұрын
This video was great. Thank you 👍
@finkelkop7204
@finkelkop7204 Жыл бұрын
Realy good explanation. TY!
@avisalon4730
@avisalon4730 2 жыл бұрын
Thanks! Very understandable video. Easy to learn.
@rizaldi4563
@rizaldi4563 3 жыл бұрын
Omg! Thankyou so much!!!
@MrPflanzmann
@MrPflanzmann 2 жыл бұрын
I love this videos. Great work!
@andythedishwasher1117
@andythedishwasher1117 Жыл бұрын
So I recently just made my first foray into Rust by attempting to build a calculator in a Yew app. I am still struggling with the logic itself, but I actually found the battle with the borrow checker to be one of the more refreshing sorts of problems I ran into. It made me think so much harder about where I was declaring my variables and where I was mutating them that it kinda just felt like my brain was steadily increasing in mass and wrinkle count the whole time.
@kellyrankin8844
@kellyrankin8844 Жыл бұрын
this is how I sort of interpreted it.."stop doing these things unless you really need to because they're just problematic"
@sundaymanali5854
@sundaymanali5854 2 жыл бұрын
10:53 gold info here. love this channel
@user-bu3hz5be5w
@user-bu3hz5be5w Жыл бұрын
Thanks! Very good explanation!
@workflowinmind
@workflowinmind 2 жыл бұрын
I needed this! Thanks
@hamzadlm6625
@hamzadlm6625 Жыл бұрын
I love u, thanks for the clear explanation
@nikhilsinha2191
@nikhilsinha2191 Жыл бұрын
I have watched tilll 17:19 and can say the explanation is top notch took me 45 min to react this point as I am coding as well the information which I find useful will continue from here the next day
@aleksandrbakhmach9810
@aleksandrbakhmach9810 Жыл бұрын
Awesome, thanks man!
@fennecfox2366
@fennecfox2366 8 ай бұрын
Coming from c++ this is intuitive. Unique pointers and move semantics give this type of behavior as options in modern c++ so having them as the default makes sense. Also having the const as default on refs is another good safety measure. I do think a basic understanding of pointers in c and references and smart pointers in c++ will help people understandownership and the ideas it's built upon.
@_pro_grammer_
@_pro_grammer_ 3 ай бұрын
finally learning rust 💙
@hanshaun1350
@hanshaun1350 7 ай бұрын
This is BY FAR the hardest part to learn Rust. It's frustrating to learn without any C background tbh.
@xquilt
@xquilt 19 күн бұрын
I genuinely don't understand that claim. I might get that you'd 'appreciate it more' not having to deal with either garbage collection/erroneous manual memory management, but not having C/C++ being a prerequisite to learn rust
@MultiKB13
@MultiKB13 2 жыл бұрын
This video is incredible, I can’t believe you don’t have more subs
@glebirovich4519
@glebirovich4519 3 жыл бұрын
Hey mate! Keep going! Very well explained.
@letsgetrusty
@letsgetrusty 3 жыл бұрын
Thanks Gleb!
@rusty9060
@rusty9060 2 жыл бұрын
17:16 is such an elegant info. I love how they designed Rust language
@googleuser2016
@googleuser2016 2 жыл бұрын
Great tutorial!
@sentimentalbaboon4262
@sentimentalbaboon4262 2 жыл бұрын
Great video, thank you!
@asjn3e
@asjn3e 2 жыл бұрын
for my new job i have to learn rust fast and i'm not really good at reading documentations and books so thank you for great and useful videos
@marlonou8818
@marlonou8818 2 жыл бұрын
Save me time reading thru the chapter myself 😄
@LuisMateoAriasCaicedo
@LuisMateoAriasCaicedo Ай бұрын
Thank you very much!
@ChrisHalden007
@ChrisHalden007 Жыл бұрын
Great video. Thanks
@hansrudolf5849
@hansrudolf5849 Жыл бұрын
Great job!
@tahsinulhaqueabir1046
@tahsinulhaqueabir1046 Жыл бұрын
Best video on rust ownership
@foobar1269
@foobar1269 2 жыл бұрын
Thank you for explaining stack and heap. Now Rust makes more sense in terms of making some of the code design pattern decisions.
@_jdfx
@_jdfx 2 жыл бұрын
Still a great video! thank you!
@ksnyou
@ksnyou 3 жыл бұрын
good explanation
@uovo
@uovo Жыл бұрын
You are a machine gun of free and high quality knowledge wow
@GlobalYoung7
@GlobalYoung7 2 жыл бұрын
Thank you. 😀🥳
@JavierGonzalez-rc5kx
@JavierGonzalez-rc5kx 2 жыл бұрын
Great video!
@ronny332
@ronny332 3 ай бұрын
What I really like about your videos, until now :-), is the speed, you tell things. I'm not native American or English, but most every tutorial I watched for instance on Udemy was so slow. Of cause someone can speedup the video, but sometimes, the speaker speaks faster or changes slides, and that results in confusion. Very, very well done, again until here 🙂as I don't know more of your videos besides the seen ones.
@Ludwig_Van_Aristossine
@Ludwig_Van_Aristossine 2 жыл бұрын
FINALLY SOMEONE WHO DO STUFF IN CODE INSTEAD OF TALKING IN AIR :D
@ddastoor
@ddastoor 3 жыл бұрын
great video buddy.
@michaeljburt
@michaeljburt 25 күн бұрын
Right around 14:10 was the lightbulb moment for me. And being a long time C and C++ programmer I think I'm finally starting to see why this Rust thing makes sense... What a clever way to make sure that we know who is writing data and who is just reading or calling getters. It makes the C/C++ way of using references, pointers and const seem kind of silly.
@sheikhakbar2067
@sheikhakbar2067 3 жыл бұрын
Thanks a lot.
@letsgetrusty
@letsgetrusty 3 жыл бұрын
Most welcome!
@bzzzvzzze
@bzzzvzzze Жыл бұрын
great video!
@quangle5701
@quangle5701 2 жыл бұрын
Thanks for the video. I would like to know how to apply the slice and ownership for the array of String objects (not &str), especially when passing them to a function as arguments ? Thanks
@codelearner4449
@codelearner4449 Жыл бұрын
You're an amazing teacher thanks man. The way you expained how rust stops two mutable references in the same scope to prevent race conditions. If I am not wrong, this feature isnt there in golang, and this is where rust outshines. This feature will outshine even more, when concurrency comes into play. Explaining why rust promotes safe concurrency. Correct me if I got this right.
@snk-js
@snk-js 2 жыл бұрын
wonderful!
@cryptomando
@cryptomando 2 жыл бұрын
Great video
@HarshRajput-jr7qp
@HarshRajput-jr7qp 11 ай бұрын
great video bro
@_jirkaa_5170
@_jirkaa_5170 Жыл бұрын
When I watched 2 hour tutorial for rust and was completly confused but now its like really easy
@hieverybody4246
@hieverybody4246 7 күн бұрын
This is by far the toughest part of Rust. I really wish the book had a ton more examples and explained things far better.
@bitfluent
@bitfluent Жыл бұрын
Idk who invented the borrowing/ownership concept, but it's genius.
@jesusmtz29
@jesusmtz29 Жыл бұрын
Great video. I've been trying to watch more than a couple of times and read the book to fully understand why some types are made a copy of by default and some get's ownership transfered? What was the feature in mind?
@srinivasvalekar9904
@srinivasvalekar9904 2 жыл бұрын
*Me* : Casually starts to watch video to understand closures After sometime , Can't stop watching other videos. I was so deeply involved in listening your videos, I noticed a background music, could you please tell me which song it is :D
@davidjdoherty
@davidjdoherty Жыл бұрын
Great video. Helped clarify things for me on how this works. Do you guidance on programming styles you recommend when it comes to moving/copying/etc? E.g. when to implement methods as references vs. copies, etc. Side note, the return of the first word function was s.len(), not i. Wouldn't the correct implementation of that return i?
@reedamm
@reedamm Ай бұрын
if you cannot remember the ownership rules then here is small trick i thought of which was :- 1) each house has a one owner 2) each house can have only one owner at a time 3) when owner dies the house is broken
@miguelnogueira3552
@miguelnogueira3552 8 ай бұрын
i love you bro
@andikasaputra1390
@andikasaputra1390 Жыл бұрын
Love it
Structs in Rust
17:22
Let's Get Rusty
Рет қаралды 94 М.
Strings in Rust FINALLY EXPLAINED!
21:40
Let's Get Rusty
Рет қаралды 72 М.
船长被天使剪成光头了?#天使 #小丑 #超人不会飞
00:28
超人不会飞
Рет қаралды 4,9 МЛН
Угадайте концовку😂
00:11
Poopigirl
Рет қаралды 4,1 МЛН
Kitten has a slime in her diaper?! 🙀 #cat #kitten #cute
00:28
Điều cuối cùng mẹ có thể làm cho con || Sad Story  #shorts
01:00
Rust Ownership and Borrowing
38:21
Doug Milford
Рет қаралды 66 М.
but what is 'a lifetime?
12:20
leddoo
Рет қаралды 53 М.
Why i think C++ is better than rust
32:48
ThePrimeTime
Рет қаралды 253 М.
Rust makes you feel like a GENIUS
10:48
No Boilerplate
Рет қаралды 395 М.
All Rust features explained
21:30
Let's Get Rusty
Рет қаралды 268 М.
This Is How Rust Stops Memory Leaks
5:53
Low Level Learning
Рет қаралды 152 М.
I spent six months rewriting everything in Rust
15:11
chris biscardi
Рет қаралды 372 М.
The Rust Survival Guide
12:34
Let's Get Rusty
Рет қаралды 120 М.
Why spend $10.000 on a flashlight when these are $200🗿
0:12
NIGHTOPERATOR
Рет қаралды 16 МЛН
Распаковка айфона в воде😱 #shorts
0:25
Mevaza
Рет қаралды 1,1 МЛН
phone charge game #viral #tranding #new #reels
0:18
YODHA GAMING RAAS
Рет қаралды 7 МЛН
iPhone - телефон для нищебродов?!
0:53
ÉЖИ АКСЁНОВ
Рет қаралды 3,5 МЛН
Компьютерная мышь за 50 рублей
0:28
dizzi
Рет қаралды 1,3 МЛН