Cell<T> — copy values. RefCell<T> — borrow at runtime.
Cell<T>:
RefCell<T>:
1use std::cell::{Cell, RefCell};23// Cell4let c = Cell::new(5);5c.set(10); // No runtime check6let val = c.get(); // Copy78// RefCell9let r = RefCell::new(vec![]);10let mut borrow = r.borrow_mut();11borrow.push(1);12drop(borrow);
Key: Cell for Copy types, RefCell for runtime borrow.