pub struct Slot<'s> { /* private fields */ }
Expand description
Allows writing into a struct field or inserting into a hash map.
Implementations§
Source§impl<'s> Slot<'s>
impl<'s> Slot<'s>
Sourcepub fn for_ptr(
ptr: NonNull<u8>,
shape: ShapeDesc,
init_mark: InitMark<'s>,
) -> Self
pub fn for_ptr( ptr: NonNull<u8>, shape: ShapeDesc, init_mark: InitMark<'s>, ) -> Self
Create a new slot for writing into a struct field — not just foo.bar
, but also
foo.2
for tuples, foo.0
for newtype wrappers, etc.
Sourcepub fn for_hash_map(map: NonNull<u8>, key: String, shape: ShapeDesc) -> Self
pub fn for_hash_map(map: NonNull<u8>, key: String, shape: ShapeDesc) -> Self
Create a new slot for writing into a HashMap. This is a different kind of slot because the field has to be allocated on the heap first and then inserted into the hashmap.
Sourcepub fn fill<T: Shapely>(self, value: T)
pub fn fill<T: Shapely>(self, value: T)
Fills the slot with a value of a concrete type. This performs a type check and panics if the type is incompatible with the slot’s shape.
If the slot is already initialized, the old value is dropped.
pub fn fill_from_partial(self, partial: Partial<'_>)
pub fn shape(&self) -> ShapeDesc
Auto Trait Implementations§
impl<'s> Freeze for Slot<'s>
impl<'s> RefUnwindSafe for Slot<'s>
impl<'s> !Send for Slot<'s>
impl<'s> !Sync for Slot<'s>
impl<'s> Unpin for Slot<'s>
impl<'s> !UnwindSafe for Slot<'s>
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