smart-pointers

Box<T> for heap allocation and recursive types

Box&lt;T&gt; is Rust's simplest smart pointer: it allocates T on the heap and gives you ownership. When the Box goes out of scope, the heap memory is freed. I use Box when I need indirection (like recursive types), when moving large structs is expensi

Deref and DerefMut for smart pointer ergonomics

Implementing Deref lets your type automatically coerce to its target type. For example, Box&lt;T&gt; derefs to T, and String derefs to str. This enables method calls and conversions without explicit unwrapping. I implement Deref for wrapper types and

Rc and RefCell for shared ownership with interior mutability

When you need multiple ownership without threads, Rc&lt;T&gt; (reference counted) is the answer. It tracks the number of owners at runtime and frees the data when the count reaches zero. For mutability, combine it with RefCell&lt;T&gt;, which enforces