Quick syntax references, memory footprint summaries, and thread safety traits for standard library smart pointers and concurrency primitives.
let b = Box::new(5);Unique heap allocation. 8-byte pointer on stack. Auto-deallocated on drop.
let r = Rc::new(data); let r2 = Rc::clone(&r);Single-threaded reference counting. Shared ownership. !Send, !Sync.
let a = Arc::new(data); let a2 = Arc::clone(&a);Atomic Reference Counting. Multi-threaded shared ownership. Send + Sync (if T is Send + Sync).
let c = RefCell::new(0); *c.borrow_mut() += 1;Dynamic interior mutability. Runtime borrow checking. Panics on aliasing violations.
let m = Mutex::new(0); let mut g = m.lock().unwrap();Thread-safe mutual exclusion. Grants RAII MutexGuard giving exclusive &mut T access.
let lock = RwLock::new(data); let r = lock.read().unwrap();Multiple concurrent readers OR one exclusive writer across threads.
impl Deref for MyBox<T> { type Target = T; ... }Implicit dereferencing coercions (e.g. &String -> &str, &Vec<T> -> &[T]).
impl From<A> for B { fn from(a: A) -> Self { ... } }Value-to-value conversion. Implementing From automatically implements Into.
impl TryFrom<i64> for u8 { type Error = ...; }Fallible type conversion returning Result<T, Error>.
fn process<P: AsRef<Path>>(path: P) { ... }Cheap reference-to-reference conversion for generic function parameters.
let (tx, rx) = std::sync::mpsc::channel();Unbounded Multi-Producer, Single-Consumer FIFO queue.
let (tx, rx) = std::sync::mpsc::sync_channel(10);Bounded FIFO queue applying backpressure. Blocks senders when buffer reaches N.
thread::spawn(move || { ... });Spawns an OS-level native thread with a 2MB default stack.
thread::scope(|s| { s.spawn(|| { ... }); });Scoped threads that can borrow stack data from the parent scope without 'static.