A reference counted pointer to an object matching the virtual table
std::rc::Rc where the
VTable type parameter is a VTable struct
#[vtable], and the
X type parameter is the actual instance.
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
Other differences with the
std::rc::Rc types are:
- It does not allow to access mutable reference. (No
make_mut), meaning it is safe to get a Pin reference with
- It is safe to pass it accross ffi boundaries.
impl<VTable: VTableMetaDropInPlace, X: HasStaticVTable<VTable>> VRc<VTable, X>[src]
Create a new VRc from an instance of a type that can be associated with a VTable.
Will move the instance on the heap.
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
impl<VTable: VTableMetaDropInPlace, X> VRc<VTable, X>[src]
pub fn as_pin_ref(&self) -> Pin<&X>[src]
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
pub fn borrow_pin<'b>(this: &'b Self) -> Pin<VRef<'b, VTable>>[src]
Gets a Pin
This is safe because there is no way to access a mutable reference to the pointee.
(There is no
VWeak pointing to this instance.
pub fn strong_count(this: &Self) -> usize[src]
Gets the number of strong (VRc) pointers to this allocation.
Returns true if the two VRc's point to the same allocation
impl<VTable: VTableMetaDropInPlace + 'static, X> Clone for VRc<VTable, X>[src]
impl<VTable: VTableMetaDropInPlace, X> Deref for VRc<VTable, X>[src]
impl<VTable: VTableMetaDropInPlace + 'static, X> Drop for VRc<VTable, X>[src]
impl<VTable, X = Dyn> !RefUnwindSafe for VRc<VTable, X>
impl<VTable, X = Dyn> !UnwindSafe for VRc<VTable, X>
type Owned = T
The resulting type after obtaining ownership.
pub fn clone_into(&self, target: &mut T)[src]
type Error = Infallible
The type returned in the event of a conversion error.