Learning Rust: Memory, Ownership and Borrowing

  Рет қаралды 93,506

YouCodeThings

YouCodeThings

Күн бұрын

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....
List of Copy types: stackoverflow....
End song:
Track: LFZ - Popsicle [NCS Release] Music provided by NoCopyrightSounds. Free Download / Stream: ncs.io/PopsicleYO
You all rock!

Пікірлер: 144
@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 6 жыл бұрын
Thank you, dito.
@Manja500
@Manja500 6 жыл бұрын
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 5 жыл бұрын
This channel deserves A LOT more subscribers!
@wutong4524
@wutong4524 2 жыл бұрын
Holly crap, this video is golden
@rifaldhiaw
@rifaldhiaw 4 жыл бұрын
This is the best borrow system explanation yet!
@TBaguette
@TBaguette 5 жыл бұрын
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.
@verified_tinker1818
@verified_tinker1818 3 жыл бұрын
One of the best programming tutorials I've ever seen. Thanks!
@albert21994
@albert21994 5 жыл бұрын
this is the best programming channel I have discorvered! subbed.
@nhefner
@nhefner 2 жыл бұрын
I just started with Rust and this video was super helpful! Keep up the excellent work, you deserve way more subs!
@kaderramy4021
@kaderramy4021 5 жыл бұрын
mind blow. of how easy you make complicated rusty concepts look. keep rocking dude
@Sssssssassy
@Sssssssassy 6 жыл бұрын
I just finished reading the Ownership chapter of the book and this further solidified and clarified the lessons, thank you!
@officialabdulrehman
@officialabdulrehman 2 жыл бұрын
What a gem of a channel 💎
@Arunscape
@Arunscape 6 жыл бұрын
This is the best way I've seen ownership being explained. Thank you!
@sashalarious5990
@sashalarious5990 9 ай бұрын
Really enjoying the color scheme of this channel ☺️
@NoorquackerInd
@NoorquackerInd 4 жыл бұрын
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
@anshvashisht8519
@anshvashisht8519 Жыл бұрын
that a wonderful explanation, so much time invested in making the difficult concept clear by animation.
@flash_alexander
@flash_alexander 5 жыл бұрын
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
@avimehenwal
@avimehenwal 5 жыл бұрын
I am having so much fun learning #Rust. Thankyou you guys @YouCodeThings, these videos makes it so effortless. Thats the power of community
@DeriveIt
@DeriveIt 8 ай бұрын
This video is great. Love the call stack analogy.
@CaptMirage
@CaptMirage 2 ай бұрын
this is the best explanation i have ever seen, subbed oh yea also you dropped this : 👑
@soupnoodles
@soupnoodles 3 жыл бұрын
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!
@jackwright517
@jackwright517 Жыл бұрын
WHOA! This is super clear and well explained. 🤯
@ysuv5563
@ysuv5563 Жыл бұрын
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.
@tetuaoro
@tetuaoro 3 жыл бұрын
Ownership animation amazing thx fully
@nathanielgraham958
@nathanielgraham958 5 жыл бұрын
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.
@ragrazila
@ragrazila 4 жыл бұрын
this channel deserves many more subscribers.
@lancecarter8732
@lancecarter8732 3 жыл бұрын
Was just reading chp.4 in the Rust book and this really helped
@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.
@fahmi2978
@fahmi2978 6 жыл бұрын
The Friendly way to Learn Rust , and i love it . Thanks mate
@DwarkeshPatel
@DwarkeshPatel 4 жыл бұрын
This is such great content. Thank you!
@ailuros_
@ailuros_ 5 жыл бұрын
Nice style making video. Very fun!
@docentealejandrocarrillo471
@docentealejandrocarrillo471 4 жыл бұрын
This video is more explained than the Rust Book.
@joelmontesdeoca6572
@joelmontesdeoca6572 2 жыл бұрын
This explanation was amazing!
@Tr3Gee
@Tr3Gee 5 жыл бұрын
Thanks for such a clear explanation. The animations really helped, lol. Thank you YouCodeThings
@jithind-feverx2818
@jithind-feverx2818 3 жыл бұрын
Ownership explained clearly ❤️❤️
@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!
@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
@borys4206
@borys4206 2 жыл бұрын
I like your videos and its style! Thanks!
@shibasispatel6624
@shibasispatel6624 5 жыл бұрын
You are a great teacher. Glad I found your channel..
@xbony2
@xbony2 4 жыл бұрын
This is hella professional, great work.
@anchalgupta4860
@anchalgupta4860 15 күн бұрын
Best video ever
@oroneki
@oroneki 6 жыл бұрын
Oh! (...) my! (...) God! That is gooold! Thanks so much! Cheers from Brazil!
@vedantnn7
@vedantnn7 3 жыл бұрын
you really teach in very nice manner, instant subscribe
@arcticspacefox864
@arcticspacefox864 5 жыл бұрын
I love your video😂 it was great and interesting! Please continue your style
@janniswildermuth1499
@janniswildermuth1499 7 ай бұрын
Really great explanation, thank you!
@guillaumebogard5880
@guillaumebogard5880 5 жыл бұрын
Your channel is amazing ! Keep up the good work :)
@LakshmipathiG
@LakshmipathiG 4 жыл бұрын
Great thanks! Excellent stuff.
@mateuszgrzonka3826
@mateuszgrzonka3826 4 жыл бұрын
Love your vids!
@blue_lobster_
@blue_lobster_ 6 жыл бұрын
Super cool video! Subscribed!
@doyourealise
@doyourealise 5 жыл бұрын
the best video on ownership amaizng
@fabiomarsiaj8172
@fabiomarsiaj8172 4 жыл бұрын
Dude your videos are super good, keep going and thank you :)
@kenny-kvibe
@kenny-kvibe 3 жыл бұрын
Good descriptive video, simple and concise, thank you!
@GlebEagle
@GlebEagle 2 жыл бұрын
Wow, this explanation is awesome!)🦀❤
@quangle5701
@quangle5701 3 жыл бұрын
Excellent explanation ! Thank you very much.
@ktlknss
@ktlknss Жыл бұрын
thanks so much, I was wondering why the & was used sometimes but now I get it!
@1337CodeMaster
@1337CodeMaster 3 жыл бұрын
Very well explained! Thank you so much :D
@YouCodeThings
@YouCodeThings Жыл бұрын
You're welcome!
@EngineerNick
@EngineerNick 4 жыл бұрын
Thankyou for this clear explanation :)
@ruis2345
@ruis2345 4 жыл бұрын
Well explained, hats off
@WizardOfArc
@WizardOfArc 5 жыл бұрын
These are entertaining and informative - thank you
@cyko5950
@cyko5950 5 ай бұрын
this is brilliant
@tengkuizdihar
@tengkuizdihar 6 жыл бұрын
Wow this is well explained and really consice and clear. Very good job.
@TheOMGPoPCorn
@TheOMGPoPCorn 5 жыл бұрын
Just what I needed. Great job!
@harrimahlstrom7706
@harrimahlstrom7706 4 жыл бұрын
Realy good explanation!!!
@AbhishekNigam
@AbhishekNigam 5 жыл бұрын
Explained really well!
@niravprajapati1267
@niravprajapati1267 2 жыл бұрын
Good work :)
@Nate-gi7no
@Nate-gi7no 4 жыл бұрын
SICK VIDEO!
@phildevtv409
@phildevtv409 2 жыл бұрын
Thx for great explanation!
@elimgarak3597
@elimgarak3597 4 жыл бұрын
Great video! Thank you so much!
@hagenlens1403
@hagenlens1403 4 жыл бұрын
This video is so fucking great.
@gbrls_yt
@gbrls_yt 5 жыл бұрын
Hey man! good job, keep it up
@dusvn1484
@dusvn1484 Ай бұрын
Nice video!
@renatajakubowicz9664
@renatajakubowicz9664 6 жыл бұрын
Thanks for teaching Rust!
@YummyRed
@YummyRed 4 жыл бұрын
Maaan, you should make more learning videos. It's damn funny and useful.
@thengakola6217
@thengakola6217 3 жыл бұрын
No, ur an amazing person *inserts keanu.jpg*
@YouCodeThings
@YouCodeThings Жыл бұрын
*blushes* Oh you
@KarimAlbakry
@KarimAlbakry 6 жыл бұрын
you forgot to mention that this only for reference types not value types
@wishnuprathikantam
@wishnuprathikantam 4 жыл бұрын
Hey @youcodethings Great content 👍, please do more videos , if possible regularly!
@bharathhariharan4750
@bharathhariharan4750 4 жыл бұрын
Why aren't you making new videos...your videos are great.
@YouCodeThings
@YouCodeThings 4 жыл бұрын
Appreciate it! A lot going on. Currently working on some larger game projects. Want to eventually make some videos on that process.
@orochi639
@orochi639 Жыл бұрын
Good explanation
@henrytan5707
@henrytan5707 4 жыл бұрын
Love it.
@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
@darkcheese1
@darkcheese1 4 жыл бұрын
nice explanation, thank you :)
@kcru240
@kcru240 4 жыл бұрын
I feel you sound like Dr. Seuss: there is a nice rhythm to the way you talk.
@andersmusikka
@andersmusikka 4 жыл бұрын
What microphone do you use? You have spectacularly good audio quality.
@ladyViviaen
@ladyViviaen 3 жыл бұрын
i FINALLY learned pointers
@YouCodeThings
@YouCodeThings Жыл бұрын
Yay!
@cd-stephen
@cd-stephen Жыл бұрын
good vid ty - new sub
@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
@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
@michelkazi3112
@michelkazi3112 4 жыл бұрын
Holy shit. I understood this.
@geeksesi
@geeksesi 5 жыл бұрын
amazing. thank you.
@codewithnws3544
@codewithnws3544 Жыл бұрын
Hey can you share the idea of creating this video like in the 2d drawing with the animation, what softwaresthat you had used?
@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 ;)
@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 6 жыл бұрын
Make a playlist of this!
@aeroball8360
@aeroball8360 6 жыл бұрын
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_ 5 жыл бұрын
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!
@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 2 жыл бұрын
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).
@kangalio
@kangalio 6 жыл бұрын
Thank you! ^.^
@YouCodeThings
@YouCodeThings 6 жыл бұрын
Thank you for the suggestion!!! :)
@Pluvo2for1
@Pluvo2for1 2 жыл бұрын
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 Жыл бұрын
Yep!
@JoshuaKisb
@JoshuaKisb 6 жыл бұрын
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
@jasdfpasdfakdsjhfa
@jasdfpasdfakdsjhfa 3 ай бұрын
Nice video but people learning Rust probably don't need an explanation of what the heap and stack are.
@IshanDassanayake07
@IshanDassanayake07 16 күн бұрын
&mut str is not possible as &str is immutable
@howard-n6d
@howard-n6d 6 ай бұрын
I like how this dude pronounce data as "d a t a"
Making a Snake Game in Rust
8:13
YouCodeThings
Рет қаралды 94 М.
Understanding Ownership in Rust
25:30
Let's Get Rusty
Рет қаралды 279 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Rust Ownership and Borrowing
38:21
Doug Milford
Рет қаралды 69 М.
Use Arc Instead of Vec
15:21
Logan Smith
Рет қаралды 167 М.
The Rust Survival Guide
12:34
Let's Get Rusty
Рет қаралды 180 М.
04 Ownership & Borrowing | Rust Tutorials
8:42
Jeff No Zhao
Рет қаралды 11 М.
Traits and You: A Deep Dive - Nell Shamrell-Harrington
22:09
Rust Belt Rust Conference
Рет қаралды 40 М.
8 deadly mistakes beginner Rust developers make
14:14
Let's Get Rusty
Рет қаралды 182 М.
Rust for TypeScript devs : Borrow Checker
8:49
ThePrimeagen
Рет қаралды 235 М.
Rust Demystified 🪄 Simplifying The Toughest Parts
14:05
Code to the Moon
Рет қаралды 195 М.
Rust String vs str slices
14:58
Doug Milford
Рет қаралды 24 М.
This Is How Rust Stops Memory Leaks
5:53
Low Level
Рет қаралды 171 М.