[−][src]Struct deno_core::RcRef
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]
source: R,
map_fn: F
) -> RcRef<T>
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]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,