Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRustRc<RefCell<T>> combosSingle-choice MCQ

Why does this code fail to compile, even though `RefCell` allows interior mutability?

use std::rc::Rc; use std::cell::RefCell; use std::thread; fn main() { let data = Rc::new(RefCell::new(0)); let d2 = Rc::clone(&data); thread::spawn(move || { *d2.borrow_mut() += 1; }); }