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
impl<T> RcRef<AsyncRefCell<T>>
[src]
impl<T> RcRef<AsyncRefCell<T>>
[src]pub fn borrow(&self) -> AsyncRefFuture<T>
[src]
pub fn borrow_mut(&self) -> AsyncMutFuture<T>
[src]
pub fn try_borrow(&self) -> Option<AsyncRef<T>>
[src]
pub fn try_borrow_mut(&self) -> Option<AsyncMut<T>>
[src]
Trait Implementations
impl<T: 'static> RcLike<T> for RcRef<T>
[src]
impl<T: 'static> RcLike<T> for &RcRef<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for RcRef<T>
impl<T> !Send for RcRef<T>
impl<T> !Sync for RcRef<T>
impl<T> Unpin for RcRef<T>
impl<T> !UnwindSafe for RcRef<T>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more