[−][src]Struct option_lock::OptionLock
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]
fn from(lock: OptionLock<T>) -> Self
[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,
T: Unpin,
impl<T> UnwindSafe for OptionLock<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[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]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,