[−][src]Struct vtable::VBox
An equivalent of a Box that holds a pointer to a VTable and a pointer to an instance. A VBox frees the instance when dropped.
The type parameter is supposed to be the VTable type.
The VBox implements Deref so one can access all the members of the vtable.
This is only valid if the VTable has a drop
type (so that the #[vtable]
macro
implements the VTableMetaDrop
trait for it)
Implementations
impl<T: ?Sized + VTableMetaDrop> VBox<T>
[src]
pub fn new<X: HasStaticVTable<T>>(value: X) -> Self
[src]
Create a new VBox 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)
pub unsafe fn from_raw(vtable: NonNull<T::VTable>, ptr: NonNull<u8>) -> Self
[src]
Safety: the ptr
needs to be a valid for the vtable
, and properly allocated so it can be dropped
pub fn borrow<'b>(&'b self) -> VRef<'b, T>
[src]
Gets a VRef pointing to this box
pub fn borrow_mut<'b>(&'b mut self) -> VRefMut<'b, T>
[src]
Gets a VRefMut pointing to this box
pub fn leak(self) -> VRefMut<'static, T>
[src]
Leaks the content of the box.
Trait Implementations
impl<T: ?Sized + VTableMetaDrop> Deref for VBox<T>
[src]
type Target = T::Target
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<T: ?Sized + VTableMetaDrop> DerefMut for VBox<T>
[src]
impl<T: ?Sized + VTableMetaDrop> Drop for VBox<T>
[src]
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for VBox<T> where
<T as VTableMeta>::Target: RefUnwindSafe,
<T as VTableMeta>::Target: RefUnwindSafe,
impl<T> !Send for VBox<T>
impl<T> !Sync for VBox<T>
impl<T: ?Sized> Unpin for VBox<T> where
<T as VTableMeta>::Target: Unpin,
<T as VTableMeta>::Target: Unpin,
impl<T: ?Sized> UnwindSafe for VBox<T> where
<T as VTableMeta>::Target: UnwindSafe,
<T as VTableMeta>::Target: UnwindSafe,
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,
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, 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.
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>,