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

Why does this code panic at runtime?

use std::rc::Rc; use std::cell::RefCell; fn main() { let data = Rc::new(RefCell::new(5)); let r1 = data.borrow(); let mut r2 = data.borrow_mut(); *r2 += 1; }