[][src]Struct option_lock::OptionLock

pub struct OptionLock<T> { /* fields omitted */ }

A read/write lock around an Option value.

Implementations

impl<T> OptionLock<T>[src]

pub const fn empty() -> Self[src]

Create a new, empty instance.

pub const fn new(value: T) -> Self[src]

Create a new populated instance.

pub fn is_some_unlocked(&self) -> bool[src]

Check if there is a stored value and no guard held.

pub fn is_none_unlocked(&self) -> bool[src]

Check if there is no stored value and no guard held.

pub fn is_locked(&self) -> bool[src]

Check if a guard is held.

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

Get a mutable reference to the contained value, if any.

pub fn into_inner(self) -> Option<T>[src]

Unwrap an owned lock instance.

pub fn spin_lock(&self) -> OptionGuard<'_, T>[src]

In a spin loop, wait to acquire the lock.

pub fn spin_lock_none(&self) -> OptionGuard<'_, T>[src]

In a spin loop, wait to acquire the lock with a value of None.

pub fn spin_take(&self) -> T[src]

In a spin loop, wait to take a value from the lock.

pub fn try_lock(&self) -> Option<OptionGuard<'_, T>>[src]

Try to acquire an exclusive lock.

On successful acquisition Some(OptionGuard<'_, T>) is returned, representing an exclusive read/write lock.

pub fn try_lock_none(&self) -> Option<OptionGuard<'_, T>>[src]

Try to acquire an exclusive lock, but only if the value is currently None.

On successful acquisition Some(OptionGuard<'_, T>) is returned, representing an exclusive read/write lock.

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

Try to take a stored value from the lock.

On successful acquisition Some(T) is returned.

On failure, None is returned. Acquisition can fail either because there is no contained value, or because the lock is held by a guard.

pub fn replace(&mut self, value: T) -> Option<T>[src]

Replace the value in an owned OptionLock.

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

Take the value (if any) from an owned OptionLock.

Trait Implementations

impl<T> Debug for OptionLock<T>[src]

impl<T> Default for OptionLock<T>[src]

impl<T> Drop for OptionLock<T>[src]

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

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

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

impl<T> Into<Option<T>> for OptionLock<T>[src]

impl<T: Send> Send for OptionLock<T>[src]

impl<T: Send> Sync for OptionLock<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for OptionLock<T>

impl<T> Unpin for OptionLock<T> where
    T: Unpin

impl<T> UnwindSafe for OptionLock<T> where
    T: UnwindSafe

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<!> for T[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.