pub struct Slot<T: ?Sized>(/* private fields */);Expand description
Wraps a mutable borrow for storage in LaneContext.
This erases the lifetime so the value can be stored in the type-map.
The caller must ensure the Slot does not outlive the original
reference (guaranteed by the stack-scoped context pattern).
ⓘ
use khora_core::lane::Slot;
let mut encoder: Box<dyn CommandEncoder> = /* ... */;
let slot = Slot::new(encoder.as_mut());
// slot.get() -> &mut dyn CommandEncoderImplementations§
Source§impl<T: ?Sized> Slot<T>
impl<T: ?Sized> Slot<T>
Sourcepub unsafe fn from_raw(ptr: *mut T) -> Self
pub unsafe fn from_raw(ptr: *mut T) -> Self
Creates a Slot from a raw pointer.
§Safety
The caller must ensure:
- The pointer is valid and properly aligned.
- The pointed-to data outlives every use of this
Slot. - No other mutable reference to the data exists while the
Slotis live.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Slot<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Slot<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Unpin for Slot<T>where
T: ?Sized,
impl<T> UnwindSafe for Slot<T>where
T: RefUnwindSafe + ?Sized,
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