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

This code builds a cycle. What is the consequence regarding memory?

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(Some(Rc::clone(&a))) }); *a.next.borrow_mut() = Some(Rc::clone(&b)); }