pub struct ThreadBound<T> { /* private fields */ }
Expand description

ThreadBound is a Sync-maker and Send-maker that allows accessing a value of type T only from the original thread on which the ThreadBound was constructed.

Refer to the crate-level documentation for a usage example.

Implementations§

Binds a value to the current thread. The wrapper can be sent around to other threads, but no other threads will be able to access the underlying value.

Accesses a reference to the underlying value if this is its original thread, otherwise None.

Accesses a mutable reference to the underlying value if this is its original thread, otherwise None.

Extracts ownership of the underlying value if this is its original thread, otherwise None.

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. 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.

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.