pub struct DataStackRegisterAccess<'a> { /* private fields */ }Expand description
Handle to one register slot, taken with DataStack::access_register.
A register has a fixed type chosen when it was pushed, and is either
empty or full. Reads and takes check the requested type against the
register type and return None on a mismatch.
Implementations§
Source§impl<'a> DataStackRegisterAccess<'a>
impl<'a> DataStackRegisterAccess<'a>
Sourcepub fn type_hash_layout(&self) -> (TypeHash, Layout)
pub fn type_hash_layout(&self) -> (TypeHash, Layout)
Returns type and layout together, reading the header only once.
Sourcepub fn read<T: 'static>(&'a self) -> Option<&'a T>
pub fn read<T: 'static>(&'a self) -> Option<&'a T>
Borrows the stored value, or returns None when the register is empty
or holds another type.
Sourcepub fn write<T: 'static>(&'a mut self) -> Option<&'a mut T>
pub fn write<T: 'static>(&'a mut self) -> Option<&'a mut T>
Borrows the stored value mutably, or returns None when the register
is empty or holds another type.
Sourcepub fn take<T: 'static>(&mut self) -> Option<T>
pub fn take<T: 'static>(&mut self) -> Option<T>
Moves the value out and leaves the register empty.
Returns None when the register is empty or holds another type.
Sourcepub fn free(&mut self) -> bool
pub fn free(&mut self) -> bool
Drops the stored value in place and leaves the register empty.
Returns false when there was nothing to drop.
Auto Trait Implementations§
impl<'a> !UnwindSafe for DataStackRegisterAccess<'a>
impl<'a> Freeze for DataStackRegisterAccess<'a>
impl<'a> RefUnwindSafe for DataStackRegisterAccess<'a>
impl<'a> Send for DataStackRegisterAccess<'a>
impl<'a> Sync for DataStackRegisterAccess<'a>
impl<'a> Unpin for DataStackRegisterAccess<'a>
impl<'a> UnsafeUnpin for DataStackRegisterAccess<'a>
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