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 of
Rc`?
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.