Lesson 47 of 50 · rust
Interior Mutability with RefCell
Duration: 12 minutes
Lesson 47 of 50 · rust
Duration: 12 minutes
RefCell<T> enforces borrowing rules at runtime, allowing mutable borrows even when the RefCell is immutable.\n\nrust\nuse std::cell::RefCell;\n\nfn main() {\n let data = RefCell::new(vec![1, 2, 3]);\n data.borrow_mut().push(4);\n println!(\"Data: {:?}\", data.borrow());\n}\n\n