RefCell — single-threaded runtime borrow. Mutex — thread-safe lock.
RefCell:
Mutex:
1// RefCell2use std::cell::RefCell;3let r = RefCell::new(5);4*r.borrow_mut() += 1;56// Mutex7use std::sync::Mutex;8let m = Mutex::new(5);9*m.lock().unwrap() += 1;
Key: RefCell for single thread, Mutex for multi-thread.