Struct deno_core::RcRef

source ·
pub struct RcRef<T> { /* private fields */ }
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§

Converts this type into a shared reference of the (usually inferred) input type.
Immutably borrows from an owned value. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
The resulting type after dereferencing.
Dereferences the value.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.