pub struct Cryo<'a, T: ?Sized + 'a> { /* private fields */ }
Expand description
A cell-like type that enforces the lifetime restriction of its borrowed value at runtime.
Cryo
is a variation of CryoMut
that only can be immutably borrowed.
When a Cryo
is dropped, the current thread will be blocked until all
references to the contained value are dropped. This ensures that none of
the references can outlive the referent.
See the module-level documentation for more details.
Implementations
sourceimpl<'a, T: ?Sized + 'a> Cryo<'a, T>
impl<'a, T: ?Sized + 'a> Cryo<'a, T>
sourcepub unsafe fn new(x: &'a T) -> Self
pub unsafe fn new(x: &'a T) -> Self
Construct a new Cryo
.
Safety
-
The constructed
Cryo
must not be moved around. This might result in a dangling pointer inCryoRef
. -
The constructed
Cryo
must not be disposed without dropping (e.g., passed tostd::mem::forget
). This might result in a dangling pointer inCryoRef
.
Trait Implementations
impl<'a, T: ?Sized + Send> Send for Cryo<'a, T>
impl<'a, T: ?Sized + Send + Sync> Sync for Cryo<'a, T>
Auto Trait Implementations
impl<'a, T> !RefUnwindSafe for Cryo<'a, T>
impl<'a, T: ?Sized> Unpin for Cryo<'a, T>
impl<'a, T: ?Sized> UnwindSafe for Cryo<'a, T>where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more