Struct vtable::VRc[][src]

#[repr(transparent)]
pub struct VRc<VTable: VTableMetaDropInPlace + 'static, X = Dyn> { /* fields omitted */ }
Expand description

A reference counted pointer to an object matching the virtual table T

Similar to std::rc::Rc where the VTable type parameter is a VTable struct annotated with #[vtable], and the X type parameter is the actual instance. When X is the Dyn type marker, this means that the X is not known and the only thing that can be done is to get a VRef<VTable> through the Self::borrow() function.

Other differences with the std::rc::Rc types are:

  • It does not allow to access mutable reference. (No get_mut or make_mut), meaning it is safe to get a Pin reference with borrow_pin.
  • It is safe to pass it across ffi boundaries.

Implementations

Create a new VRc from an instance of a type that can be associated with a VTable.

Will move the instance on the heap.

(the HasStaticVTable is implemented by the “MyTrait”VTable_static! macro generated by the #vtable macro)

Convert a VRc of a real instance to a VRc of a Dyn instance

Create a Pinned reference to the inner.

This is safe because we don’t allow mutable reference to the inner

Gets a VRef pointing to this instance

Gets a Pin pointing to this instance

This is safe because there is no way to access a mutable reference to the pointee. (There is no get_mut or make_mut),

Construct a VWeak pointing to this instance.

Gets the number of strong (VRc) pointers to this allocation.

Returns true if the two VRc’s point to the same allocation

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The resulting type after dereferencing.

Dereferences the value.

Executes the destructor for this type. Read more

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.