logo
pub struct RwLockWriteGuard<'a, T> where
    T: ?Sized
{ /* private fields */ }
Expand description

A guard that releases the write lock when dropped.

Implementations

Downgrades into a regular reader guard.

Examples
use async_lock::{RwLock, RwLockWriteGuard};

let lock = RwLock::new(1);

let mut writer = lock.write().await;
*writer += 1;

assert!(lock.try_read().is_none());

let reader = RwLockWriteGuard::downgrade(writer);
assert_eq!(*reader, 2);

assert!(lock.try_read().is_some());

Downgrades into an upgradable reader guard.

Examples
use async_lock::{RwLock, RwLockUpgradableReadGuard, RwLockWriteGuard};

let lock = RwLock::new(1);

let mut writer = lock.write().await;
*writer += 1;

assert!(lock.try_read().is_none());

let reader = RwLockWriteGuard::downgrade_to_upgradable(writer);
assert_eq!(*reader, 2);

assert!(lock.try_write().is_none());
assert!(lock.try_read().is_some());

assert!(RwLockUpgradableReadGuard::try_upgrade(reader).is_ok())

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.