🔍 Code With Me in Rust: Implementing the Strategy Pattern with Boxed Trait Objects - Part 2
Continuing in my exploration of Rust, in this video, I clean up my implementation of boxed trait objects achieving two goals: allowing the closure to capture a value without moving it and sharing variable between by trait objects and the code that creates those objects. To do that, I have to explore two important Rust features: lifetime for the first goal and RefCells for the second. RefCells move the borrow checking to run-time, so there are some scope things we have to very careful about! Finally, I need to plan where to go from here and I could use your advice! 🔧 Topics Covered: - static vs. parameterized lifetimes - RefCells - Rust's borrowing rules - How to control borrowed and mutably borrowed references so that we don't break the borrowing rules at run time 🔗 Resources: - How do I store a closure in a struct: https://stackoverflow.com/questions/27831944/how-do-i-store-a-closure-in-a-struct-in-rust 📌 Chapters: 00:00 Introduction 00:17 The problems I need to fix 01:02 Improvements I'd like to make 01:28 Getting rid of the "move" 03:34 Using a RefCell to share access 05:18 Controlling the borrows so they don't overlap 06:34 Conclusion and next steps Don't forget to like, subscribe, and hit the bell icon for more programming explorations! 👍 If this helped you think like a developer, hit like, subscribe, and tap that bell 🔔 so you don’t miss the next part! CHECK OUT MY OTHER VIDEOS: Rust Programming Playlist: https://www.youtube.com/playlist?list=PLZLC5AM_r9AjYwkudkKvO0yHX3zv3sDV2 C Programming Playlist: https://www.youtube.com/playlist?list=PLZLC5AM_r9Ag0CZdGTUm3FWhBDX28B0Dj Intro to Java Playlist: https://www.youtube.com/playlist?list=PLZLC5AM_r9Ajo6LH_-g7dXjZemaQ5QXnV Software Engineering Topics Playlist: https://www.youtube.com/playlist?list=PLZLC5AM_r9AgMHq42vUXHkXEws3JWdnDb
Download
0 formatsNo download links available.