[][src]Struct alloc_tls::TLSSlot

pub struct TLSSlot<T> { /* fields omitted */ }

A slot for a thread-local variable.

A TLSSlot should be initialized using the internal_thread_local! macro. See its documentation for details on declaring and using thread-local variables.

Methods

impl<T> TLSSlot<T>[src]

pub unsafe fn with<R, F: FnOnce(&T) -> R>(&self, f: F) -> Option<R>[src]

Access the TLS slot.

with accepts a function that will be called with a reference to the TLS value. If the slot is in the initializing or dropped state, with will return None without invoking f. If the slot is in the uninitialized state, with will initialize the value and then call f. If the slot is in the initialized state, with will call f. In either of these last two cases, with will return Some(r), where r is the value returned from the call to f.

Safety

with is unsafe because if f panics, it causes undefined behavior.

Trait Implementations

impl<T> Sync for TLSSlot<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for TLSSlot<T>

impl<T> !Send for TLSSlot<T>

impl<T> Unpin for TLSSlot<T> where
    T: Unpin

impl<T> UnwindSafe for TLSSlot<T> where
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.