pub struct LocalItem<T> { /* private fields */ }Expand description
A scope-local item.
Implementations§
Source§impl<T: Send + Sync + 'static> LocalItem<T>
impl<T: Send + Sync + 'static> LocalItem<T>
Sourcepub fn with<R>(&self, operation: impl for<'access> FnOnce(&'access T) -> R) -> R
pub fn with<R>(&self, operation: impl for<'access> FnOnce(&'access T) -> R) -> R
Runs operation with the value selected by the active scope.
The higher-ranked closure prevents a reference into per-CPU-selected storage from escaping after preemption is re-enabled.
Sourcepub fn with_pinned<R>(
&self,
pin: &CpuPin<'_>,
operation: impl for<'access> FnOnce(&'access T) -> R,
) -> R
pub fn with_pinned<R>( &self, pin: &CpuPin<'_>, operation: impl for<'access> FnOnce(&'access T) -> R, ) -> R
Runs operation under an existing CPU pin.
Sourcepub fn try_with_pinned<R>(
&self,
pin: &CpuPin<'_>,
operation: impl for<'access> FnOnce(&'access T) -> R,
) -> Option<R>
pub fn try_with_pinned<R>( &self, pin: &CpuPin<'_>, operation: impl for<'access> FnOnce(&'access T) -> R, ) -> Option<R>
Runs operation without lazy initialization under an existing pin.
This returns None when the active scope or item has not yet been
initialized, allowing hard-IRQ callers to avoid allocation.
Sourcepub fn clone_current(&self) -> Twhere
T: Clone,
pub fn clone_current(&self) -> Twhere
T: Clone,
Clones the selected value while keeping the CPU pin lifetime short.
Sourcepub fn scope<'scope>(&self, scope: &'scope Scope) -> ScopeItem<'scope, T>
pub fn scope<'scope>(&self, scope: &'scope Scope) -> ScopeItem<'scope, T>
Returns a reference to this item within the given scope.
Sourcepub fn scope_mut<'scope>(
&self,
scope: &'scope mut Scope,
) -> ScopeItemMut<'scope, T>
pub fn scope_mut<'scope>( &self, scope: &'scope mut Scope, ) -> ScopeItemMut<'scope, T>
Returns a mutable reference to this item within the given scope.
Auto Trait Implementations§
impl<T> Freeze for LocalItem<T>
impl<T> RefUnwindSafe for LocalItem<T>where
T: RefUnwindSafe,
impl<T> Send for LocalItem<T>where
T: Send,
impl<T> Sync for LocalItem<T>where
T: Sync,
impl<T> Unpin for LocalItem<T>where
T: Unpin,
impl<T> UnsafeUnpin for LocalItem<T>
impl<T> UnwindSafe for LocalItem<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