pub struct VRefMut<'a, T: ?Sized + VTableMeta> { /* private fields */ }
Expand description
VRefMut<'a MyTraitVTable>
can be thought as a &'a mut dyn MyTrait
It will dereference to a structure that has the same members as MyTrait.
Implementations§
source§impl<'a, T: ?Sized + VTableMeta> VRefMut<'a, T>
impl<'a, T: ?Sized + VTableMeta> VRefMut<'a, T>
sourcepub fn new<X: HasStaticVTable<T>>(value: &'a mut X) -> Self
pub fn new<X: HasStaticVTable<T>>(value: &'a mut X) -> Self
Create a new VRef from a mutable reference of a type that can be associated with a VTable.
(the HasStaticVTable
is implemented by the “MyTrait”VTable_static!
macro generated by
the #vtable macro)
sourcepub unsafe fn from_raw(vtable: NonNull<T::VTable>, ptr: NonNull<u8>) -> Self
pub unsafe fn from_raw(vtable: NonNull<T::VTable>, ptr: NonNull<u8>) -> Self
Create a new VRefMut from raw pointers
§Safety
The ptr
needs to be a valid object fitting the vtable
.
Both vtable and ptr lifetime must outlive ’a.
Can create mutable reference to ptr, so no other code can create mutable reference of ptr
during the life time ’a.
sourcepub fn borrow_mut(&mut self) -> VRefMut<'_, T>
pub fn borrow_mut(&mut self) -> VRefMut<'_, T>
Borrow this to obtain a new VRefMut.
sourcepub fn into_ref(self) -> VRef<'a, T>
pub fn into_ref(self) -> VRef<'a, T>
Create a VRef with the same lifetime as the original lifetime.
sourcepub fn downcast<X: HasStaticVTable<T>>(&mut self) -> Option<&mut X>
pub fn downcast<X: HasStaticVTable<T>>(&mut self) -> Option<&mut X>
Return a reference of the given type if the type is matching.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T: ?Sized> RefUnwindSafe for VRefMut<'a, T>
impl<'a, T> !Send for VRefMut<'a, T>
impl<'a, T> !Sync for VRefMut<'a, T>
impl<'a, T: ?Sized> Unpin for VRefMut<'a, T>
impl<'a, T> !UnwindSafe for VRefMut<'a, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more