Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRustRc and ArcSingle-choice MCQ

This program compiles but leaks memory. Why?

use std::rc::Rc; use std::cell::RefCell; struct Node { next: RefCell<Option<Rc<Node>>>, } fn main() { let a = Rc::new(Node { next: RefCell::new(None) }); let b = Rc::new(Node { next: RefCell::new(None) }); *a.next.borrow_mut() = Some(Rc::clone(&b)); *b.next.borrow_mut() = Some(Rc::clone(&a)); }