[][src]Struct deno_core::RcRef

pub struct RcRef<T> { /* fields omitted */ }

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]

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]

impl<T: 'static> RcRef<T>[src]

pub fn new(value: T) -> Self[src]

pub fn map<S: 'static, R: RcLike<S>, F: FnOnce(&S) -> &T>(
    source: R,
    map_fn: F
) -> RcRef<T>
[src]

Trait Implementations

impl<T> AsRef<T> for RcRef<T>[src]

impl<T> Borrow<T> for RcRef<T>[src]

impl<T> Clone for RcRef<T>[src]

impl<T: Debug> Debug for RcRef<T>[src]

impl<T: Default + 'static> Default for RcRef<T>[src]

impl<T> Deref for RcRef<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: 'static, '_> From<&'_ Rc<T>> for RcRef<T>[src]

impl<T: 'static, '_> From<&'_ RcRef<T>> for RcRef<T>[src]

impl<T: 'static> From<Rc<T>> for RcRef<T>[src]

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>[src]

impl<T> !Send for RcRef<T>[src]

impl<T> !Sync for RcRef<T>[src]

impl<T> Unpin for RcRef<T>[src]

impl<T> !UnwindSafe for RcRef<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.