Understand Rust's Borrow Checker in 5 Minutes
Vložit
- čas přidán 22. 10. 2021
- The borrow checker is probably the hardest thing about Rust to understand, which is why I'm explaining it early on. Maybe I missed a few things, oh well.
Music Used:
Late Night Radio Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 3.0 License
creativecommons.org/licenses/b...
Hyperfun Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 3.0 License
creativecommons.org/licenses/b... - Hry
Excellent video for a Java guy like me! Liked the intro quite a bit.
Very good video! Good explanations and the visuals make it easier to interperet
Thank you! This is the best borrow-checker/mutability/ownership explanation I've seen so far... Could you do one on lifetimes?
Anyone notice the purple bug? Not animated in RUST
Lol for some reason one of the purple guys had a fragment that kept flying around, and I couldn't figure out what caused it before I released it
I thought it's a flea walking on my phone screen 😂
literally watched twice thinking it was a coded message. gonna watch again to learn about the borrow checker
Excellent animations !!!! Really picture is worth of thousand words !!!
I only didn't understand puprose of this falling red dot
I like the vibe
Thanks for this :)
pretty goooooood stuff
this video is awesome
It's mut not mut 😡
"Mutt" 💀
Awesome vid and lmao memory management in narc voice
Can you help the beginner? Is there a possibility for borrow-checker to help to control partial structure updates? I mean can I pass the whole structure to the functions and in&out but borrow checker could help/nag in case called function changed a field value but the rest of the caller function code assumes the value has not been changed/updated? Can you show an example for the structure with the basic u32/int fields?
check with chatgpt
Understanding Rust's Borrow Checker in 5 seconds:
compile-time rwlock.
Thanks bro, i have an exam tomorrow and rust is one of the potential exam questions. This is exactly what i needed to know, nothing more
What school is this? I'm curious where they actually teach rust
Needed this
Good old MS Paint videos
Please please please, don't use floats for Money.
Off by 1 errors start causing havoc in systems where reconciliation and governance is paramount.
Purple bug 😂
Im sorry but i just dont understand how this isnt just the same thing as reference to a const value? So Rusts big claim to fame is that everything is const by default? What am I missing here?
The way I get it, rusts big claim to fame is in the borrow-checker. Rust is so strict with who is responsible for a piece of memory that it gives you a compile-time error if theres something it doesnt like.
Why is this so useful?
Some programs have to be low level and have no room for errors. In C, a lot of memory errors will only be caught at runtime which is not good because developers have to test every case to find errors. Rust tells you this during compile time which eliminates a lot of testing work, guaranteeing memory safety without needing to run 100 tests
Rust's big claim to fame is that all references contain a lifetime parameter that lets the compiler figure out how long a reference has lived for, to determine if the reference can outlive the value it's pointing to and throw an compiler error if it can. In some cases the lifetime parameter is inferred by the compiler, meaning that you don't need to explicitly state that it exists in your code, but in other cases the compiler can't trivially infer it and so it requires that you manually state it by adding a lifetime annotation to variables containing references, which the compiler can use to "string together" the full lifetime of a given reference as it moves through your code.
Basically, imagine if you were writing some C code and you referenced a variable to get a pointer to the value of that variable, then you stored the pointer in another struct so that you can refer back to the variable at a later time. In C you'd have to look over the code to make sure that the struct can't possibly outlive the variable that the pointer is pointing to, else you'd have a user-after-free which could cause a segfault, or worse. In Rust that pointer has a lifetime parameter associated with it that tells the Rust compiler how long the pointer has lived for, and the struct would accept its own lifetime parameter that associates the struct's lifetime with the pointer's. That lets the compiler make sure that the pointer doesn't outlive the value it's pointing to, which means you don't have to look over the code as much as you would in C. That is Rust's big claim to fame.
...half assed coverage of topic, promises to continue it but abandons completely...downvote.