pub struct TaskLocal<T: 'static> { /* private fields */ }Expand description
A key for task-local storage, created by the [task_local!] macro.
Each static TaskLocal<T> has a unique address used as the storage key.
Implementations§
Source§impl<T: 'static> TaskLocal<T>
impl<T: 'static> TaskLocal<T>
Sourcepub fn scope<F: Future>(&'static self, value: T, future: F) -> Scope<T, F> ⓘ
pub fn scope<F: Future>(&'static self, value: T, future: F) -> Scope<T, F> ⓘ
Run future with value set for this key. Restores the previous
value (if any) after each poll, so other tasks on the same thread
don’t see stale data.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TaskLocal<T>
impl<T> RefUnwindSafe for TaskLocal<T>where
T: RefUnwindSafe,
impl<T> Send for TaskLocal<T>where
T: Send,
impl<T> Unpin for TaskLocal<T>where
T: Unpin,
impl<T> UnsafeUnpin for TaskLocal<T>
impl<T> UnwindSafe for TaskLocal<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more