Struct generational_box::GenerationalBox
source · pub struct GenerationalBox<T, S: 'static = UnsyncStorage> { /* private fields */ }
Expand description
The core Copy state type. The generational box will be dropped when the Owner is dropped.
Implementations§
source§impl<T, S: Storage<T>> GenerationalBox<T, S>
impl<T, S: Storage<T>> GenerationalBox<T, S>
sourcepub fn leak(value: T) -> Self
pub fn leak(value: T) -> Self
Create a new generational box by leaking a value into the storage. This is useful for creating a box that needs to be manually dropped with no owners.
sourcepub fn id(&self) -> GenerationalBoxId
pub fn id(&self) -> GenerationalBoxId
Get the id of the generational box.
sourcepub fn try_read(&self) -> Result<S::Ref<'static, T>, BorrowError>
pub fn try_read(&self) -> Result<S::Ref<'static, T>, BorrowError>
Try to read the value. Returns None if the value is no longer valid.
sourcepub fn read(&self) -> S::Ref<'static, T>
pub fn read(&self) -> S::Ref<'static, T>
Read the value. Panics if the value is no longer valid.
sourcepub fn try_write(&self) -> Result<S::Mut<'static, T>, BorrowMutError>
pub fn try_write(&self) -> Result<S::Mut<'static, T>, BorrowMutError>
Try to write the value. Returns None if the value is no longer valid.
sourcepub fn write(&self) -> S::Mut<'static, T>
pub fn write(&self) -> S::Mut<'static, T>
Write the value. Panics if the value is no longer valid.
sourcepub fn ptr_eq(&self, other: &Self) -> bool
pub fn ptr_eq(&self, other: &Self) -> bool
Returns true if the pointer is equal to the other pointer.
sourcepub fn manually_drop(&self) -> Option<T>
pub fn manually_drop(&self) -> Option<T>
Drop the value out of the generational box and invalidate the generational box. This will return the value if the value was taken.
Trait Implementations§
source§impl<T, S> Clone for GenerationalBox<T, S>
impl<T, S> Clone for GenerationalBox<T, S>
source§impl<T, S: AnyStorage> Debug for GenerationalBox<T, S>
impl<T, S: AnyStorage> Debug for GenerationalBox<T, S>
impl<T, S> Copy for GenerationalBox<T, S>
Auto Trait Implementations§
impl<T, S> Freeze for GenerationalBox<T, S>
impl<T, S = UnsyncStorage> !RefUnwindSafe for GenerationalBox<T, S>
impl<T, S> Send for GenerationalBox<T, S>
impl<T, S> Sync for GenerationalBox<T, S>
impl<T, S> Unpin for GenerationalBox<T, S>where
T: Unpin,
impl<T, S = UnsyncStorage> !UnwindSafe for GenerationalBox<T, 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