Rust Memory Management - Ownership and Borrowing

Rust Memory Management - Ownership and Borrowing

Tensor Programming

4 года назад

34,004 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@TensorProgramming
@TensorProgramming - 18.12.2019 05:56

Hey guys, I know I've already covered Ownership on this channel. I must confess that I was never satisfied with that video. Now that we are aiming to talk about Async Await in Rust, I figured that it would be prime time to refresh this video due to the prominence of 'static and Sized data as well as the Smart Pointers like the Pin and Atomics like Arc and Mutex. I'm hoping that the explanation is different enough that you guys will have learned something even if you already know the concepts.

Btw, just to preempt all of the incoming comments, yes I misspoke, u8 is 8 bits not bytes. Yet another tragedy of my dyslexia. Sorry about that guys. Also aware that I typed in a string slice and not a character. Character literals in Rust use single quotes not double quotes; that one was pure negligence on my part.

Ответить
@AnumodhNK
@AnumodhNK - 29.07.2023 00:18

This is one of the best explanation I have seen on Rust Memory model and Ownership. I am bookmarking this video. Great work and Thank you.

Ответить
@hoangnguyenhong7499
@hoangnguyenhong7499 - 26.02.2023 11:36

What an explanation. You deserve to have 10 girlfriends with this. many thanks.

Ответить
@ShashwathKamath
@ShashwathKamath - 07.02.2023 22:21

best explanation

Ответить
@oussaber
@oussaber - 27.12.2022 11:24

Best explanation of the stack ever!

Ответить
@1969dksoondk1969
@1969dksoondk1969 - 23.07.2022 01:16

This was very useful, but you really need to slow down and give the viewer a few seconds to assimilate the info before you move on. Hold pauses between your points :-)

Ответить
@RobertoGimenez
@RobertoGimenez - 17.06.2022 05:35

Strings can be on the stack. It's contents are on the heap. Structures in general can be on the stack also.

Ответить
@bonehelm
@bonehelm - 28.04.2022 23:22

Huh, cool. Sounds very similar to unique_ptr in c++, except ALL heap allocations are unique_ptr by default all the time.

Ответить
@Bruh-hd4rj
@Bruh-hd4rj - 15.04.2022 23:09

Great video ! Can you give me the name of the color scheme you are using ?

Ответить
@ChaseMoskal
@ChaseMoskal - 19.02.2022 05:45

so great norm macdonald could teach me great programming before he passed 🙏

Ответить
@ighsight
@ighsight - 16.12.2021 05:05

Excellent work.

Ответить
@raulbache654
@raulbache654 - 04.07.2021 14:28

8 bits

Ответить
@homawong
@homawong - 28.06.2021 06:14

Great video. Small note: u8 = 8 bits, not 8 bytes.

Ответить
@jonathanmoore5619
@jonathanmoore5619 - 20.06.2021 08:03

Perfect, simple expo. Thanks.

Ответить
@jamescoppe
@jamescoppe - 30.03.2021 09:51

Great video dude

Ответить
@flokoshel1272
@flokoshel1272 - 14.02.2021 14:35

This helped me soooo much in understanding the whole stuff with ownership and borrowing. Thank you! Great explanation!

Ответить
@AlexejSailer
@AlexejSailer - 22.01.2021 14:55

Perfect explanation! Thanks!

Ответить
@dennisbarzanoff9025
@dennisbarzanoff9025 - 19.01.2021 00:55

Wow Rust is actually cool

Ответить
@happilyconfuseddog8951
@happilyconfuseddog8951 - 09.01.2021 20:34

Best video on Rust memory

Ответить
@uidx-bob
@uidx-bob - 09.12.2020 01:12

10 out of 10. Great video and explaination.

Ответить
@RusuTraianCristian
@RusuTraianCristian - 23.08.2020 01:04

Bits, not bytes. But yeah, you just made a mistake, it's not like you know it wrong. :P

Ответить
@NekonyaNyaNya1
@NekonyaNyaNya1 - 07.07.2020 22:58

this was more insightfull that description in the rust book...
thank you!

Ответить
@TheEpicFace007
@TheEpicFace007 - 01.07.2020 23:04

thank you for your explaination. it's easyb to understand.

Ответить
@sagnikbhattacharya1202
@sagnikbhattacharya1202 - 01.07.2020 21:02

wow this is amazing thank you so much!!!

Ответить
@cyberpunk2042
@cyberpunk2042 - 19.06.2020 11:28

You are a legend. What an incredible explanation, please continue to dig into these Rust concepts, would love to get more videos on Rust from you! You are one of the best people I've seen explain difficult concepts like this, superb!

Ответить
@goodwish1543
@goodwish1543 - 06.06.2020 22:19

mutable borrow example, of 3) Only allowed to pass one borrow at a time for write access/mutability.

after c borrow, only after modify/reference c end, we can touch a.
after modify/reference a again, cannot touch c.
after use a, we can continue use a.

fn main() {
let mut a = 10;
let c = &mut a;
*c += 2;
// a += 5;
println!("c {} ", c);
println!("a {} ", a);
// println!(" c {} ", c);
a += 3;
println!("a {} ", a);
}

Ответить
@lukec3758
@lukec3758 - 23.04.2020 07:51

Your series is amazing and I really enjoyed watching the projects as well. I want to build on this. Do you have some favourite crates you could send people (or just me) to go read and play with to figure some more stuff out? I use Go a lot for work and I really like cobra for cli stuff, for instance, figuring out how it worked helped me understand go.

Ответить
@frankN326
@frankN326 - 22.04.2020 19:37

This was the best explanation of stack, heap, and ownership I've seen. Coming from C# this was awesome!

Ответить
@MykMallett
@MykMallett - 16.04.2020 06:48

I had no idea Norm McDonald was a programmer

Ответить
@kitgary
@kitgary - 11.02.2020 22:03

Great tutorial! One thing I don't understand is why Rust allow mutable owner and mutable reference coexists?

Eg.
fn main()
{
let mut a_string = String::from("hello");

//If this were async, wouldn't we have a data race?
append_string(&mut a_string);

a_string.push('world!');

println!("{}", a_string);

}

fn append_string(target: &mut String) -> () {
target.push_str("world");
}

Ответить
@horaciomlhh
@horaciomlhh - 10.02.2020 06:42

great to see larger characters, qould be nice to use an editor that also uses wrap to see complete sentences when they are long! great content! keep it going
thanks

Ответить
@gerardgauthier4876
@gerardgauthier4876 - 06.02.2020 12:03

Here's an excellent book recommendation for anyone wanting a solid introduction to Rust -> Programming Rust Fast, Safe Systems Development by Jim Blandy & Jason OrenDroff, published by O'Reilly.

Ответить
@gerardgauthier4876
@gerardgauthier4876 - 05.02.2020 21:18

Yeah! The video makes it look real simple. Try writing some real world code in Rust and you'll understand why some very competent system programmers call it the most difficult language they ever experienced.
Note: I'm not saying Rust is a bad language because it isn't. Rust has some lovely features like let binding and default immutability and pattern matching and type inference but appeasing its borrow checker can be an absolute pain in the ass.
In Rust... Its Rust's way or the highway. In Rust you have to be ever conscious about the borrow checker and bend to its wishes or have a program that will never compile which is a good thing in the long run.

Ответить
@tacowilco7515
@tacowilco7515 - 05.02.2020 16:46

I turn on this video each time I have insomnia. It helps a lot. Thanks!

Ответить
@AbhishekYadav-pu4tl
@AbhishekYadav-pu4tl - 01.02.2020 20:07

That was really a great explaination. Can you please explain cases where we use the raw pointers such as *a? I'm having some trouble getting them through my head.

Ответить
@ThePandaGuitar
@ThePandaGuitar - 30.01.2020 07:53

Perfect pace and clear explanation. Thank you very much!

Ответить
@ahmedkorim6420
@ahmedkorim6420 - 22.01.2020 00:46

Great explanation Thx <3 Tensor ,Nice name by the way =D

Ответить
@connorcantrell559
@connorcantrell559 - 27.12.2019 09:14

Excellent tutorial. Clear and concise. I would like to make a request. Can you cover Utility traits such as From, Into, Deref, Borrow, ToOwned? I have spent a few weeks studying this material, and I have a decent grasp of it. However, it would be helpful to see these traits implemented in a practical example. Thanks!

Ответить
@AtticusFinch65
@AtticusFinch65 - 24.12.2019 20:14

beautiful explanation, thank you tensor

Ответить
@aymanriadsolh5605
@aymanriadsolh5605 - 20.12.2019 22:48

hello, your courses are very great and full (but i wait a video about symbols and runes in Dart 😉). I would ask you which vs code theme do you use 😅 ? thanks

Ответить
@viktormarosvary8673
@viktormarosvary8673 - 18.12.2019 19:51

Great Video! One minor correction, when you demonstrated the copy() function with "a", that was not a character but a string slice, since it was not in single quotes.

Ответить
@bilbobeutlin6979
@bilbobeutlin6979 - 18.12.2019 19:40

This is a REALLY good explanation, thank you!

Ответить
@richardsilva5136
@richardsilva5136 - 18.12.2019 16:24

The best explanation I saw about! thank you very much

Ответить
@raghav4296
@raghav4296 - 18.12.2019 16:18

G'day Tensor. I know you have been making a lot of awesome programming based tutorials. Any idea of starting up Cloud technologies tutorials would be great to learn from you on that front...Thanks.

Ответить