Struct deno_core::RcRef [−][src]
pub struct RcRef<T> { /* fields omitted */ }
Expand description
An RcRef
encapsulates a reference counted pointer, just like a regular
std::rc::Rc
. However, unlike a regular Rc
, it can be remapped so that
it dereferences to any value that’s reachable through the reference-counted
pointer. This is achieved through the associated method, RcRef::map()
,
similar to how std::cell::Ref::map()
works. Example:
struct Stuff { foo: u32, bar: String, } let stuff_rc = Rc::new(Stuff { foo: 42, bar: "hello".to_owned(), }); // `foo_rc` and `bar_rc` dereference to different types, however // they share a reference count. let foo_rc: RcRef<u32> = RcRef::map(stuff_rc.clone(), |v| &v.foo); let bar_rc: RcRef<String> = RcRef::map(stuff_rc, |v| &v.bar);
Implementations
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for RcRef<T>
impl<T> !UnwindSafe for RcRef<T>
Blanket Implementations
Mutably borrows from an owned value. Read more