Thank you so much for this video, it helped me learned a lot more about Rust than I have ever expected But I got to say programming a linked list in Rust in this safe version is way harder than other programming languages that I've used, C++ for example is so quick and easy, but I'm going all in for the safetyness Rust provides
I think YTer "Let's get rusty" has a good explanation for it in his vid about circular references. The problem with doubly-linked list is that we have structures mutually referencing each other, which have to modify each other. Can't use ownership here, but "&" or "&mut " woudn't work either since there's only one modifying reference allowed. That's too complicated for the borrow-checker and so we have to revert to thos awkward "smart pointers". Disclaimer: I'm still a Rust novice, so surely somewhat has a better explanation?
I don't think there is any null pointer optimization for Rc or Weak. It lists right there in the documentation you pointed to what types have NPO and neither are listed.
There is. println!("{}", core::mem::size_of::()); // 24 (not optimized) println!("{}", core::mem::size_of::()); // 8 println!("{}", core::mem::size_of::()); // 8 println!("{}", core::mem::size_of::()); // 8 Anything that contains a raw pointer or reference within it is usually optimized println!("{}", core::mem::size_of::()); // 24 println!("{}", core::mem::size_of::()); // 24 println!("{}", core::mem::size_of::()); // 24 println!("{}", core::mem::size_of::()); // 24
Is there no way to create a helper push_helper(self, value, a, b) and then push_front(self, value) calls push_helper(self, value, head, tail) and push_back(self, value) calls push_helper(self, value, tail, head)?
Thank you so much for this video, it helped me learned a lot more about Rust than I have ever expected
But I got to say programming a linked list in Rust in this safe version is way harder than other programming languages that I've used, C++ for example is so quick and easy, but I'm going all in for the safetyness Rust provides
Thanks very much for this one. In the process of implementing a LRU cache and wasn't 100% on double linked lists in Rust... SAVE!!
Thank you. Demystifying such topics are really needed.
I only wish you explained *WHY* you used RefCell and Rc, how you knew you needed them, etc.
year later and I'm coming back to rust and this video. do you have a video that would explain that to me?
I think YTer "Let's get rusty" has a good explanation for it in his vid about circular references. The problem with doubly-linked list is that we have structures mutually referencing each other, which have to modify each other. Can't use ownership here, but
"&" or "&mut " woudn't work either since there's only one modifying reference allowed. That's too complicated for the borrow-checker and so we have to revert to thos awkward "smart pointers".
Disclaimer: I'm still a Rust novice, so surely somewhat has a better explanation?
Hi Thomas, do you have a video where you show us how you setup your IDE for Rust? Please a tutorial for VIM + Rust.
@@nyxtom thank YOU so much! ❤️
@@nyxtom Do you by any chance have dotfiles repo to have a look at? Thanks.
Comment for the algorithm god!
@@nyxtom I just don't have to say anything of value that I haven't mentioned before :D
I don't think there is any null pointer optimization for Rc or Weak. It lists right there in the documentation you pointed to what types have NPO and neither are listed.
There is.
println!("{}", core::mem::size_of::()); // 24 (not optimized)
println!("{}", core::mem::size_of::()); // 8
println!("{}", core::mem::size_of::()); // 8
println!("{}", core::mem::size_of::()); // 8
Anything that contains a raw pointer or reference within it is usually optimized
println!("{}", core::mem::size_of::()); // 24
println!("{}", core::mem::size_of::()); // 24
println!("{}", core::mem::size_of::()); // 24
println!("{}", core::mem::size_of::()); // 24
Thank you 😊
Bro what theme are you using?
Is there no way to create a helper push_helper(self, value, a, b) and then push_front(self, value) calls push_helper(self, value, head, tail) and push_back(self, value) calls push_helper(self, value, tail, head)?