Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRustRefCell and interior mutabilitySingle-choice MCQ

Using `Ref::map(c.borrow(), |t| &t.0)` to project into a tuple field, is the `RefCell` still considered borrowed while the returned guard is alive?

use std::cell::{RefCell, Ref}; fn main() { let c = RefCell::new((1, 2)); let first = Ref::map(c.borrow(), |t| &t.0); println!("{}", c.try_borrow_mut().is_err()); // ? drop(first); }