We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
← All tracks
0 / 4
Smart Pointers and Interior Mutability
Rust`Box`, `Rc`, `RefCell`, `Weak`, `Deref`, `Cow` — and the honest arena-vs-`Rc<RefCell<_>>` argument, taught arena-first so the interior-mutability cliff is a choice rather than a trap.
This track is written for Rust, which isn't the mode you're browsing in.
0
/ 22 solved
· 4 articles
- 1. Not solved yet. The stack, the heap, and `Box<T>`
- 2. Not solved yet. Recursive types need indirection: E0072
- 3. Enum layout and niche optimization: why `Option<Box<T>>` is free Read
- 4. Not solved yet. `large_enum_variant`: boxing the fat variant
- 5. Not solved yet. `Rc<T>`: shared ownership by reference counting
- 6. Not solved yet. Inside `Rc`: `strong_count`, `ptr_eq`, `get_mut`, `try_unwrap`
- 7. Not solved yet. `Rc::make_mut`: copy-on-write shared data
- 8. Not solved yet. `Rc<str>`: interning without double indirection
- 9. Shared does not mean immutable Read
- 10. Not solved yet. `Cell<T>`: mutation by moving values in and out
- 11. Not solved yet. `RefCell<T>`: borrowing checked at runtime
- 12. Not solved yet. When `RefCell` panics: re-entrancy and borrows held too long
- 13. Not solved yet. `let _ =` versus `let _x =`: the guard that dies instantly
- 14. Not solved yet. RAII: build your own guard
- 15. Not solved yet. `Rc<RefCell<T>>`: the workhorse, and when it is a smell
- 16. Not solved yet. Reference cycles leak memory
- 17. Not solved yet. `Weak<T>`: non-owning references that break cycles
- 18. Not solved yet. `Rc::new_cyclic`: self-reference in one step
- 19. `Deref` is for smart pointers, and nothing else Read
- 20. Not solved yet. `OnceCell`: write-once interior mutability
- 21. Not solved yet. `static mut` is dead: what edition 2024 changed
- 22. Not solved yet. Indices as handles: the generational arena
- 23. Not solved yet. Bake-off: the same tree, an arena and an `Rc` graph
- 24. Not solved yet. Drop order in composite structures
- 25. Not solved yet. Build `Cell<T>` and `RefCell<T>` from scratch
- 26. Choosing a smart pointer Read
Check yourself
4 questions · one attempt eachThese do not count toward finishing the track. They are here to catch the things that are easy to read past.
What does Rc::clone copy, and when is the value freed?
let rc = Rc::new(5);
{ let _c = Rc::clone(&rc); Rc::strong_count(&rc) }
Rc::strong_count(&rc)
Question 1 of 4