Why Rc has get_mut, but not get?


#1

E.g. when I need a multiple read only reference to the underlying object it seems that the only option is Rc<RefCell<T>> but why this is not just part ofRc`?


#2

Rc does have this ability through its implementation of the Deref trait. You can explicitly call rc.deref() (if you use std::ops::Deref;), or get a reference with &*rc. And you should be able to “auto-deref” through it, so rc.foo() can dereference and call foo(&self) on the inner type.