[][src]Struct cryo::CryoMut

pub struct CryoMut<'a, T: ?Sized + 'a> { /* fields omitted */ }

A cell-like type that enforces the lifetime restriction of its borrowed value at runtime.

CryoMut is a variation of Cryo that can be mutably borrowed.

When a CryoMut 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.

Methods

impl<'a, T: ?Sized + 'a> CryoMut<'a, T>[src]

pub unsafe fn new(x: &'a mut T) -> Self[src]

Construct a new CryoMut.

Safety

  • The constructed CryoMut must not be moved around. This might result in a dangling pointer in CryoMut*Guard.

  • The constructed CryoMut must not be disposed without dropping (e.g., passed to std::mem::forget). This might result in a dangling pointer in CryoMut*Guard.

pub fn read(&self) -> CryoMutReadGuard<T>[src]

Acquire a read (shared) lock on a CryoMut.

pub fn try_read(&self) -> Option<CryoMutReadGuard<T>>[src]

Attempt to acquire a read (shared) lock on a CryoMut.

pub fn write(&self) -> CryoMutWriteGuard<T>[src]

Acquire a write (exclusive) lock on a CryoMut.

pub fn try_write(&self) -> Option<CryoMutWriteGuard<T>>[src]

Attempt to acquire a write (exclusive) lock on a CryoMut.

pub fn try_get_mut(&mut self) -> Option<&mut T>[src]

Attempt to mutably borrow a CryoMut using compile-time lifetime rules.

Returns None if the CryoMut is already borrowed via CryoMutReadGuard or CryoMutWriteGuard.

Trait Implementations

impl<'a, T: ?Sized + Debug> Debug for CryoMut<'a, T>[src]

impl<'a, T: ?Sized + 'a> Drop for CryoMut<'a, T>[src]

impl<'a, T: ?Sized + Send> Send for CryoMut<'a, T>[src]

impl<'a, T: ?Sized + Send + Sync> Sync for CryoMut<'a, T>[src]

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for CryoMut<'a, T>

impl<'a, T: ?Sized> Unpin for CryoMut<'a, T>

impl<'a, T> !UnwindSafe for CryoMut<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.