Smart Pointers in Rust - Interior Mutability

preview_player
Показать описание
The ultimate Rust lang tutorial. Follow along as we go through the Rust lang book chapter by chapter.

Chapters:
0:00​ Intro
1:09 Enforcing Borrowing Rules at Runtime
3:36 Interior Mutability Pattern
5:31 Interior Mutability: Mock Objects
13:00 Borrowing Rules with RefCell
14:07 Combining Rc and RefCell
16:41 Outro

#letsgetrusty​​ #rust​lang​ #tutorial
Рекомендации по теме
Комментарии
Автор

I dont have a long attention span to go through the book sometimes, watching your videos really help me refocused. Thank you so much!

Angelilicia
Автор

Great stuff. Broken down so simply. Rust is fantastic. This is the type of stuff that C’s syntax lets your burn yourself on so easily. And this C++ was forced to lemming after it.

The verbosity of syntax around this is a feature, and it makes your wonderful explanation as simple as just reading the code.

Great language, great channel, great content! Thanks for saving me tons of time :D

arisweedler
Автор

usize adapts to u32 or u64, depending on the architecture of the computer (32/64 bits). It's more "portable" to write it this way.

julianferres
Автор

I'm sitting here having a cocktail, and moving on to some nice whisky. This video is amazing! The content is very clear, and for me it's just reinforcing the idea that rust really isn't that different or special compared to other languages I know, it's just really explicit. You need to be absolutely clear about what you need a particular reference to do, and it's all built into the type system. Wonderful. Thankyou for this video.

stephensurtees
Автор

Borrow checking at runtime? I feel like if I have to use RefCell, there is something wrong with my design pattern.

brianteague
Автор

Was waiting for this, keep it up bogdan!

herrxerex
Автор

The Halting Problem…. That was quite a curve ball in this context.

Nice

thegeniusfool
Автор

I wanted to build undirected graphs in rust, so I used unsafe rust to store addresses as *const <Node>, here Node is a custom struct, but then I thought I could that in C++ too and then whats the point of compile time checks if we are happening to have checks at runtime, so this video helped a lot : ). But, yeah RefCell's implementation is 'unsafe', so checks at runtime only.

DakshKaushik-il
Автор

Hi Bogdan,
thank you very much for all your videos !!! keep doing it, they are great!

jakubwojciech
Автор

Another super useful and enlightening video. Great work as always. Thank you!

markmcdonnell
Автор

Great Video.💕

But just one suggestion.

You should use Cell instead of RefCell in the Cons-list example. As i32 is a copy type, Cell is a better choice as it doesn't have a runtime overhead like RefCell.
I feel like for copy types RefCell is an overkill.

technoflask
Автор

I just wanna smash the like button infinite times bro !! Fantastic content 👍 need more rusty stuff

bjugdbjk
Автор

Excellent video. It's all about combining.

Автор

Great! But how can I handle the Panic and go on with my program?

kampkrieger
Автор

Should we use smart pointers or is this an indication that we need to restructure our code? My question comes down to "Is this a cheat or bandaid for a problem with our project's architecture?"

Galakyllz
Автор

I'm a noob and I dont seem to understand why do we this instead of :
pub trait Messenger {
fn send(&mut self, msg: &str);
}

just making a mutable self reference

solomon
Автор

Hmm, how is that manual ref counting actually better than something like a read write smart pointer in C++? It doesn't really check anything at compile time, so it's all runtime. And if it's all runtime it can still just panic. Which is functionally same as using a weak_ptr etc. Seems like there should be some very strong rules of thumb about when to use that. If I just sprincle RefCell all over the place, it seems to defeat the point of the language.

julkiewitz
Автор

Could this be abstracted somehow? Seems unnecessarily complicated

myronkipa
Автор

great easy to understand, can you do the Fearless concurrency chapter? thanks

codeultima
Автор

Help! I am trying to write macros! A macro series would be great! 😁

CompletelyCovered
visit shbcf.ru