Learning Rust: Memory, Ownership and Borrowing

  Рет қаралды 89,844

YouCodeThings

YouCodeThings

6 жыл бұрын

We go to some strange places in the computer...
* A rough model of the stack and heap.
* Copy and Cloning values
* The three rules of ownership
* Immutable and mutable borrows
* Slice borrowing
The Rust book: doc.rust-lang.org/book/second...
List of Copy types: stackoverflow.com/a/41413595
End song:
Track: LFZ - Popsicle [NCS Release] Music provided by NoCopyrightSounds. Free Download / Stream: ncs.io/PopsicleYO
You all rock!

Пікірлер: 138
@taylorallred6208
@taylorallred6208 5 жыл бұрын
That was one of the greatest analogies for teaching scope I have ever seen. Also, thank you for helping me understand rust's ownership!
@YouCodeThings
@YouCodeThings 5 жыл бұрын
Cheers! Glad the video was useful :)
@brianhechinger8715
@brianhechinger8715 Жыл бұрын
I'm only finding this video three years later but I just have to echo this. I've always struggled explaining stack/heap to people and this analogy makes it so super simple. I'm totally stealing this. 😀
@YouCodeThings
@YouCodeThings 6 жыл бұрын
You're an amazing person!
@ichdich2332
@ichdich2332 5 жыл бұрын
Thank you, dito.
@Debianz
@Debianz 5 жыл бұрын
I can see you haven't made any videos in a while. Please don't give up, your doing great. I know KZbin channel growth can be slow, but you will get there at some point. Love the videos, keep up the great work.
@mikailkhan9166
@mikailkhan9166 5 жыл бұрын
no u
@HermanWillems
@HermanWillems 4 жыл бұрын
Did you just comment this to your own video? :) haha you must feel amazing about your own personality :D
@itsr4yd946
@itsr4yd946 4 жыл бұрын
This channel deserves A LOT more subscribers!
@kaderramy4021
@kaderramy4021 5 жыл бұрын
mind blow. of how easy you make complicated rusty concepts look. keep rocking dude
@TBaguette
@TBaguette 4 жыл бұрын
Please continue making videos, you're clearly one of the funniest and best channels about programming ever ! I'd even say that if one day Rust becomes more popular, your channel could become very successful ! I really enjoy your Rust videos, I hope more are coming soon.
@albert21994
@albert21994 5 жыл бұрын
this is the best programming channel I have discorvered! subbed.
@simonwtong
@simonwtong 5 жыл бұрын
I just finished reading the Ownership chapter of the book and this further solidified and clarified the lessons, thank you!
@verified_tinker1818
@verified_tinker1818 2 жыл бұрын
One of the best programming tutorials I've ever seen. Thanks!
@avimehenwal
@avimehenwal 4 жыл бұрын
I am having so much fun learning #Rust. Thankyou you guys @YouCodeThings, these videos makes it so effortless. Thats the power of community
@Arunscape
@Arunscape 5 жыл бұрын
This is the best way I've seen ownership being explained. Thank you!
@nhefner
@nhefner Жыл бұрын
I just started with Rust and this video was super helpful! Keep up the excellent work, you deserve way more subs!
@rifaldhiaw
@rifaldhiaw 3 жыл бұрын
This is the best borrow system explanation yet!
@anshvashisht8519
@anshvashisht8519 Жыл бұрын
that a wonderful explanation, so much time invested in making the difficult concept clear by animation.
@NoorquackerInd
@NoorquackerInd 3 жыл бұрын
Every KZbin video about Rust is always at least half an hour long and I've put off learning just because of that, but finally I've found something good
@interceptings8624
@interceptings8624 Жыл бұрын
ACTUALLY SUCH A GOOD VIDEO i like the animations and explanations just makes it that much easier from going from something i know to jibberish code
@soupnoodles
@soupnoodles 2 жыл бұрын
Really loved this video, especially the out-of-scope lesson Really didn't get into my head just by reading the book, this was super useful!
@fahmi2978
@fahmi2978 5 жыл бұрын
The Friendly way to Learn Rust , and i love it . Thanks mate
@officialabdulrehman
@officialabdulrehman Жыл бұрын
What a gem of a channel 💎
@wutong4524
@wutong4524 Жыл бұрын
Holly crap, this video is golden
@sashalarious5990
@sashalarious5990 3 ай бұрын
Really enjoying the color scheme of this channel ☺️
@borys4206
@borys4206 2 жыл бұрын
I like your videos and its style! Thanks!
@flash_alexander
@flash_alexander 4 жыл бұрын
I wish to have similar videos covering the entirety of rust? your videos are vivid and make it easy to understand Rust for a programmer
@Tr3Gee
@Tr3Gee 5 жыл бұрын
Thanks for such a clear explanation. The animations really helped, lol. Thank you YouCodeThings
@jackwright517
@jackwright517 7 ай бұрын
WHOA! This is super clear and well explained. 🤯
@tetuaoro
@tetuaoro 3 жыл бұрын
Ownership animation amazing thx fully
@DeriveIt
@DeriveIt 2 ай бұрын
This video is great. Love the call stack analogy.
@ailuros_
@ailuros_ 4 жыл бұрын
Nice style making video. Very fun!
@lancecarter8732
@lancecarter8732 2 жыл бұрын
Was just reading chp.4 in the Rust book and this really helped
@arcticspacefox864
@arcticspacefox864 4 жыл бұрын
I love your video😂 it was great and interesting! Please continue your style
@joelmontesdeoca6572
@joelmontesdeoca6572 2 жыл бұрын
This explanation was amazing!
@guillaumebogard5880
@guillaumebogard5880 5 жыл бұрын
Your channel is amazing ! Keep up the good work :)
@shibasispatel6624
@shibasispatel6624 4 жыл бұрын
You are a great teacher. Glad I found your channel..
@rajanpoudel3787
@rajanpoudel3787 6 жыл бұрын
subscribing to your channel is the best thing that happen to me. loved your tutorials.
@YouCodeThings
@YouCodeThings 6 жыл бұрын
Thanks for leaving a comment and subscribing!!! :) Your comment is the best thing that's happened to me.
@WizardOfArc
@WizardOfArc 5 жыл бұрын
These are entertaining and informative - thank you
@DwarkeshPatel
@DwarkeshPatel 4 жыл бұрын
This is such great content. Thank you!
@janniswildermuth1499
@janniswildermuth1499 20 күн бұрын
Really great explanation, thank you!
@TheOMGPoPCorn
@TheOMGPoPCorn 5 жыл бұрын
Just what I needed. Great job!
@mateuszgrzonka3826
@mateuszgrzonka3826 4 жыл бұрын
Love your vids!
@ragrazila
@ragrazila 3 жыл бұрын
this channel deserves many more subscribers.
@LakshmipathiG
@LakshmipathiG 4 жыл бұрын
Great thanks! Excellent stuff.
@xbony2
@xbony2 3 жыл бұрын
This is hella professional, great work.
@tengkuizdihar
@tengkuizdihar 5 жыл бұрын
Wow this is well explained and really consice and clear. Very good job.
@fabiomarsiaj8172
@fabiomarsiaj8172 4 жыл бұрын
Dude your videos are super good, keep going and thank you :)
@GlebEagle
@GlebEagle Жыл бұрын
Wow, this explanation is awesome!)🦀❤
@jithind-feverx2818
@jithind-feverx2818 2 жыл бұрын
Ownership explained clearly ❤️❤️
@quangle5701
@quangle5701 3 жыл бұрын
Excellent explanation ! Thank you very much.
@nathanielgraham958
@nathanielgraham958 4 жыл бұрын
I came across your video while trying to figure out why I got errors no matter where I tried to put an '&'. At the end of the video, I looked at my code, went "huh," and typed a single '&' next to one of my variable calls. Immediately every red squiggly line disappeared. Thank you! You explained ownership in an extremely helpful way.
@kenny-kvibe
@kenny-kvibe 3 жыл бұрын
Good descriptive video, simple and concise, thank you!
@docentealejandrocarrillo471
@docentealejandrocarrillo471 3 жыл бұрын
This video is more explained than the Rust Book.
@elimgarak3597
@elimgarak3597 3 жыл бұрын
Great video! Thank you so much!
@ruis2345
@ruis2345 4 жыл бұрын
Well explained, hats off
@oroneki
@oroneki 5 жыл бұрын
Oh! (...) my! (...) God! That is gooold! Thanks so much! Cheers from Brazil!
@EngineerNick
@EngineerNick 3 жыл бұрын
Thankyou for this clear explanation :)
@1337CodeMaster
@1337CodeMaster 2 жыл бұрын
Very well explained! Thank you so much :D
@YouCodeThings
@YouCodeThings 11 ай бұрын
You're welcome!
@blue_lobster_
@blue_lobster_ 5 жыл бұрын
Super cool video! Subscribed!
@phildevtv409
@phildevtv409 2 жыл бұрын
Thx for great explanation!
@ktlknss
@ktlknss 11 ай бұрын
thanks so much, I was wondering why the & was used sometimes but now I get it!
@harrimahlstrom7706
@harrimahlstrom7706 4 жыл бұрын
Realy good explanation!!!
@AbhishekNigam
@AbhishekNigam 5 жыл бұрын
Explained really well!
@vedantnn7
@vedantnn7 2 жыл бұрын
you really teach in very nice manner, instant subscribe
@adinesh7989
@adinesh7989 6 жыл бұрын
Great video. Too much work into each video. I like it.
@YouCodeThings
@YouCodeThings 6 жыл бұрын
Thank you! I got way too into those animations in this video!
@renatajakubowicz9664
@renatajakubowicz9664 6 жыл бұрын
Thanks for teaching Rust!
@gbrls_yt
@gbrls_yt 5 жыл бұрын
Hey man! good job, keep it up
@niravprajapati1267
@niravprajapati1267 2 жыл бұрын
Good work :)
@Nate-gi7no
@Nate-gi7no 3 жыл бұрын
SICK VIDEO!
@henrytan5707
@henrytan5707 4 жыл бұрын
Love it.
@penta5421
@penta5421 4 жыл бұрын
Damn, didn't understand this up until now. After watching the video, it kind of clicked and I actually understood! Thanks :D
@doyourealise
@doyourealise 4 жыл бұрын
the best video on ownership amaizng
@veggiefoodadventure
@veggiefoodadventure 3 жыл бұрын
nice explanation, thank you :)
@YummyRed
@YummyRed 4 жыл бұрын
Maaan, you should make more learning videos. It's damn funny and useful.
@orochi639
@orochi639 11 ай бұрын
Good explanation
@hagenlens1403
@hagenlens1403 4 жыл бұрын
This video is so fucking great.
@wishnuprathikantam
@wishnuprathikantam 4 жыл бұрын
Hey @youcodethings Great content 👍, please do more videos , if possible regularly!
@geeksesi
@geeksesi 4 жыл бұрын
amazing. thank you.
@ysuv5563
@ysuv5563 5 ай бұрын
I had to laugh so hard after seeing the angry face at 2:00 I have very little sleep, but this made me laugh hard. Thank you for making me laugh and thank you for the explanation.
@cd-stephen
@cd-stephen Жыл бұрын
good vid ty - new sub
@kcru240
@kcru240 4 жыл бұрын
I feel you sound like Dr. Seuss: there is a nice rhythm to the way you talk.
@KarimAlbakry
@KarimAlbakry 5 жыл бұрын
you forgot to mention that this only for reference types not value types
@aiomixrecords
@aiomixrecords 6 жыл бұрын
You are great, what do you think is the best way to represent a Cyclic Graph with multiedges in-memory store and enable parallel reads/writes concurrently to the graph? .. am coming from erlang/elixir world where the shared memory is a sin, but I could use ets(memory erlang term storage) and let the genservers/processors(independent heap) get copies from the ets , now my question, how borrowing feature is diffrenent? Is the data is copy as well like elixir? Do you recommend me to move to rust instead of elixir ? Is it possible to have more parallelism in rust more than elixir? I think parallelism algorithm highly depend on shared memory approach? Elixir and rust seem they share a lot, thank you for this amazing work
@YouCodeThings
@YouCodeThings 6 жыл бұрын
I love Elixir as well! They solve different problems. If you need something really fast where you can have a very good understanding of the nuts and bolts, I'd choose Rust. Elixir has a larger ecosystem (due to the Erlang ecosystem interop as well) and feels quicker to build distributed systems in. The real question is, why not both? There's a library called `Rustler` that lets you call Rust from elixir. This might be useful if you have a small piece you need to make performant. Finally check out this conference talk. It's an actor library written in Rust, and demonstrates some incredible features. "Type Safe & High Perf distributed actor systems with Rust" - kzbin.info/www/bejne/p6OceIeKiLmSes0 Thanks for the comment! =D
@aiomixrecords
@aiomixrecords 6 жыл бұрын
Thank you a lot for your quick response, i actually was thinking of enabling both to work together where rust work as engine for the graph and receive requests from genservers(elixir)(handling concurrent connections) this way I will take the best from the two languages. thanks again for this amazing content, pls keep up the good work. All the best, am going to watch the link ;)
@kangalio
@kangalio 6 жыл бұрын
Thank you! ^.^
@YouCodeThings
@YouCodeThings 6 жыл бұрын
Thank you for the suggestion!!! :)
@thengakola6217
@thengakola6217 3 жыл бұрын
No, ur an amazing person *inserts keanu.jpg*
@YouCodeThings
@YouCodeThings 9 ай бұрын
*blushes* Oh you
@michelkazi3112
@michelkazi3112 4 жыл бұрын
Holy shit. I understood this.
@codewithnws3544
@codewithnws3544 6 ай бұрын
Hey can you share the idea of creating this video like in the 2d drawing with the animation, what softwaresthat you had used?
@paroxyzm21
@paroxyzm21 10 ай бұрын
What about tuples? Those also should have fixed size, so should be stored on the stack? BTW. Thank you for a great video!
@JoshuaKisb
@JoshuaKisb 5 жыл бұрын
hey this looks like the programming language i was thinking of one day making. except i dont understand why they changed the syntax, whats with all that ! ! stuff and why does it become read only when borrowed. i dont get that
@ladyViviaen
@ladyViviaen 3 жыл бұрын
i FINALLY learned pointers
@YouCodeThings
@YouCodeThings 9 ай бұрын
Yay!
@davidgromer2117
@davidgromer2117 3 жыл бұрын
Hi, at 4:11 you made an example which does not allow a copy of x to a because of rule 2. So far I understand this. Could you please explain why a copy would be ok if we would assign the following: let x = "Hello World"; let a = x; println!("{},{}", a, b); So there must be a difference between let x = "Hello World" and let x = String::from("Hello World"). I heared something about string literal and string type but I do no really get the difference. Is "Hello World" stored at the stack? Thanks
@YouCodeThings
@YouCodeThings 6 жыл бұрын
Tell me, what can I do to become the best coding channel for you?
@wildtiger670
@wildtiger670 6 жыл бұрын
Give us more! :D
@natecoley160
@natecoley160 6 жыл бұрын
give us examples of that is rust was created for - safe async/parallel programming.
@ubermons
@ubermons 5 жыл бұрын
Make a playlist of this!
@aeroball8360
@aeroball8360 5 жыл бұрын
my only suggestion is slower pace. Watching your videos on normal speed is like watching other coding videos at x2 speed. If someone wants it faster they can always up the speed at normal quality, but trying to down the speed to 0.75 is weird and sounds choppy thanks to however youtube is encoding the speed change.
@ailuros_
@ailuros_ 4 жыл бұрын
You have done an amazing job so far. I wish your videos had subtitles but I know it's so hard. Maybe speaking a little bit slower it's a tip too, since I am not a native english speaker. That said, this channel is great! Keep it up!
@marusdod3685
@marusdod3685 4 жыл бұрын
ive never programmed in rust before, but why shouldnt we be able to have two pointers pointing to the same address? Like if I just wanted to iterate over an array or linkedlist I would probably need many variables pointing to the same location
@andersmusikka
@andersmusikka 4 жыл бұрын
What microphone do you use? You have spectacularly good audio quality.
@laviray5447
@laviray5447 2 жыл бұрын
4:42 when the variable X becomes invalid, what exactly then it equals to? what will be the value of X when it comes invalid?
@wutong4524
@wutong4524 Жыл бұрын
When it becomes invalid, its value is still "hello", but isn't anymore after it became invalid. If you try to access it, it will throw an error (The compiler will throw an error because it's intelligent).
@Pluvo2for1
@Pluvo2for1 Жыл бұрын
Is the idea of the heap the same as c++? That is, the heap is extra memory the program requests from the OS while the program is running?
@YouCodeThings
@YouCodeThings 11 ай бұрын
Yep!
@henkroth
@henkroth 3 жыл бұрын
I really got alot from this. My ADHD needs to be spoonfed stuff sometimes :P
@king_james_official
@king_james_official Жыл бұрын
7:18 wouldn't &a[0..2] return hel? same for the second one, it's one letter too long
@bharathhariharan4750
@bharathhariharan4750 3 жыл бұрын
Why aren't you making new videos...your videos are great.
@YouCodeThings
@YouCodeThings 3 жыл бұрын
Appreciate it! A lot going on. Currently working on some larger game projects. Want to eventually make some videos on that process.
@lionelprestes
@lionelprestes 2 жыл бұрын
make more rust tutorials plzzzzzzzzzzzzzzzz
@ajinkyax
@ajinkyax 4 жыл бұрын
I watched the video 2 times. And it s all clear now. Very fun to watch and good info. Thanks. There is still a confusing things for me like just a * and &* and
@Jack_in_the
@Jack_in_the 2 жыл бұрын
our usernames are basically the same
@YouCodeThings
@YouCodeThings 2 жыл бұрын
:O also nice tool assisted Fortnite!
@laughingvampire7555
@laughingvampire7555 Жыл бұрын
ok, I prefer Haskell lazyness is less of a mess
@SKyrim190
@SKyrim190 2 жыл бұрын
Why do I still find this confusing? D:
@YouCodeThings
@YouCodeThings 9 ай бұрын
You got this!
Making a Snake Game in Rust
8:13
YouCodeThings
Рет қаралды 93 М.
Rust Ownership and Borrowing
38:21
Doug Milford
Рет қаралды 67 М.
아이스크림으로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 60 МЛН
Дарю Самокат Скейтеру !
00:42
Vlad Samokatchik
Рет қаралды 8 МЛН
Scary Teacher 3D Nick Troll Squid Game in Brush Teeth White or Black Challenge #shorts
00:47
Understanding Ownership in Rust
25:31
Let's Get Rusty
Рет қаралды 246 М.
Rust makes you feel like a GENIUS
10:48
No Boilerplate
Рет қаралды 402 М.
04 Ownership & Borrowing | Rust Tutorials
8:42
Jeff No Zhao
Рет қаралды 10 М.
You Should Really Know These Traits in Rust
18:36
Oliver Jumpertz
Рет қаралды 11 М.
Traits and You: A Deep Dive - Nell Shamrell-Harrington
22:09
Rust Belt Rust Conference
Рет қаралды 39 М.
Rust Demystified 🪄 Simplifying The Toughest Parts
14:05
Code to the Moon
Рет қаралды 176 М.
Rust: What is Ownership and Borrowing?
19:42
Gary Explains
Рет қаралды 22 М.
Rust is not a faster horse
11:37
No Boilerplate
Рет қаралды 321 М.
Rust and RAII Memory Management - Computerphile
24:22
Computerphile
Рет қаралды 221 М.
but what is 'a lifetime?
12:20
leddoo
Рет қаралды 63 М.
Xiaomi SU-7 Max 2024 - Самый быстрый мобильник
32:11
Клубный сервис
Рет қаралды 356 М.
Новые iPhone 16 и 16 Pro Max
0:42
Romancev768
Рет қаралды 371 М.
تجربة أغرب توصيلة شحن ضد القطع تماما
0:56
صدام العزي
Рет қаралды 59 МЛН
Копия iPhone с WildBerries
1:00
Wylsacom
Рет қаралды 4,9 МЛН