pub struct ScopedKeyMut<T: ?Sized + 'static> { /* private fields */ }
Expand description

Type representing a thread local storage key corresponding to a mutable reference to the type parameter T.

Keys are statically allocated and can contain a reference to an instance of type T scoped to a particular lifetime. Keys provides two methods, set and with, both of which currently use closures to control the scope of their contents.

This differs from a ScopedKey because it provides access through a mutable reference. As a result, when the with(..) method is used to access the value, the key will appear unset whilst the closure is running. This is to prevent the value being borrowed a second time.

Implementations

Inserts a value into this scoped thread local storage slot for a duration of a closure.

Gets a value out of this scoped variable.

This function takes a closure which receives the value of this variable. For the duration of the closure, the key will appear unset.

Panics

This function will panic if set has not previously been called, or if the call is nested inside another (multiple mutable borrows of the same value are not allowed).

Test whether this TLS key has been set for the current thread.

Trait Implementations

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.