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, location: &'static Location<'static>) -> Self
pub fn leak(value: T, location: &'static Location<'static>) -> 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 leak_rc(value: T, location: &'static Location<'static>) -> Self
pub fn leak_rc(value: T, location: &'static Location<'static>) -> Self
Create a new reference counted 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 an error 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 set(&self, value: T)where
T: 'static,
pub fn set(&self, value: T)where
T: 'static,
Set 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)where
T: 'static,
pub fn manually_drop(&self)where
T: 'static,
Drop the value out of the generational box and invalidate the generational box.
Sourcepub fn created_at(&self) -> Option<&'static Location<'static>>
pub fn created_at(&self) -> Option<&'static Location<'static>>
Try to get the location the generational box was created at. In release mode this will always return None.
Sourcepub fn leak_reference(&self) -> BorrowResult<GenerationalBox<T, S>>
pub fn leak_reference(&self) -> BorrowResult<GenerationalBox<T, S>>
Get a reference to the value
Sourcepub fn point_to(&self, other: GenerationalBox<T, S>) -> BorrowResult
pub fn point_to(&self, other: GenerationalBox<T, S>) -> BorrowResult
Change this box to point to another generational box