Struct token_cell::core::TokenCell

source ·
pub struct TokenCell<T: ?Sized, Token: TokenTrait> { /* private fields */ }
Expand description

A Cell that shifts the management of access permissions to its inner value onto a Token.

Implementations§

Methods from Deref<Target = UnsafeCell<T>>§

Gets a mutable pointer to the wrapped value.

This can be cast to a pointer of any kind. Ensure that the access is unique (no active references, mutable or not) when casting to &mut T, and ensure that there are no mutations or mutable aliases going on when casting to &T

Examples
use std::cell::UnsafeCell;

let uc = UnsafeCell::new(5);

let five = uc.get();

Returns a mutable reference to the underlying data.

This call borrows the UnsafeCell mutably (at compile-time) which guarantees that we possess the only reference.

Examples
use std::cell::UnsafeCell;

let mut c = UnsafeCell::new(5);
*c.get_mut() += 1;

assert_eq!(*c.get_mut(), 6);

Trait Implementations§

The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Constructs a new cell using token as its key.
Attempts to construct a guard which Derefs to the inner data, but also allows recovering the Token.
Attempts to borrow the inner data. Read more
Attempts to construct a guard which DerefMuts to the inner data, but also allows recovering the Token.
Attempts to borrow the inner data mutably. Read more
Constructs a lazy computation that can then be applied using the token.
Constructs a lazy computation that can then be applied using the token.

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.

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.