Struct bufferring::storage::Slot
source · #[repr(transparent)]pub struct Slot<T> { /* private fields */ }Expand description
A slot for storing a single ring buffer item.
According to the Storage API, individual slots in the data buffer can be
initialized or uninitialized, and some may be borrowed mutably. This is a
convienience wrapper which provides both of these properties, combining both
MaybeUninit and UnsafeCell with a useful API.
Slots do not require initialization, like MaybeUninit; they are valid
even if constructed uninitialized. This allows them to be created in arrays
and the like without any work.
Implementations§
source§impl<T> Slot<T>
impl<T> Slot<T>
sourcepub unsafe fn get(self) -> T
pub unsafe fn get(self) -> T
Extract the contained item by value.
This is an unsafe function; it can only be called if the slot is known
to be initialized.
sourcepub unsafe fn get_ref(&self) -> &T
pub unsafe fn get_ref(&self) -> &T
Get a shared reference to the item.
This is an unsafe function; it can only be called if the slot is known
to be initialized, and if no unique references to the item (e.g. due to
get_int_mut()) already exist.
sourcepub unsafe fn get_mut(&mut self) -> &mut T
pub unsafe fn get_mut(&mut self) -> &mut T
Get a unique reference to the item.
This is an unsafe function; it can only be called if the slot is known
to be initialized.
sourcepub unsafe fn get_int_mut(&self) -> &mut T
pub unsafe fn get_int_mut(&self) -> &mut T
Get an interior-mutable reference to the item.
This is an unsafe function; it can only be called if the slot is known
to be initialized, and if no unique references to the item (e.g. due to
get_int_mut()) already exist.
sourcepub unsafe fn take(&mut self) -> T
pub unsafe fn take(&mut self) -> T
Take the item, leaving uninitialized data behind.
This is an unsafe function; it can only be called if the slot is known
to be initialized.
sourcepub unsafe fn drop_in_place(&mut self)
pub unsafe fn drop_in_place(&mut self)
Drop the item contained in this slot.
This is an unsafe function; it can only be called if the slot is known
to be initialized.