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
ormake_mut
), meaning it is safe to get a Pin reference withborrow_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)
Create a Pinned reference to the inner.
This is safe because we don’t allow mutable reference to the inner
Gets a Pin
This is safe because there is no way to access a mutable reference to the pointee.
(There is no get_mut
or make_mut
),
Gets the number of strong (VRc) pointers to this allocation.
Trait Implementations
Auto Trait Implementations
impl<VTable, X> RefUnwindSafe for VRc<VTable, X> where
X: RefUnwindSafe,
<VTable as VTableMeta>::VTable: RefUnwindSafe,
impl<VTable, X> UnwindSafe for VRc<VTable, X> where
X: RefUnwindSafe,
<VTable as VTableMeta>::VTable: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more