Struct stc_visit::visit_cache::VisitCache
source · [−]pub struct VisitCache<T>where
T: 'static,{ /* private fields */ }
Expand description
A cache for Visit
.
This prefers the first call.
Implementation details
This is inspired by scoped_tls
and tracing::subscriber::set_default()
.
Implementations
sourceimpl<T> VisitCache<T>where
T: 'static,
impl<T> VisitCache<T>where
T: 'static,
sourcepub fn configure<Ret>(&'static self, op: impl FnOnce() -> Ret) -> Ret
pub fn configure<Ret>(&'static self, op: impl FnOnce() -> Ret) -> Ret
Runs op
with the cache configured.
If the cache is already configured, this does nothing.
sourcepub fn insert(&'static self, key: *const (), value: T)
pub fn insert(&'static self, key: *const (), value: T)
Insert a value into the cache. Noop if the cache is not configured.
pub fn get_copied(&'static self, key: *const ()) -> Option<T>where
T: Copy,
pub fn get<F, Ret>(&'static self, key: *const (), op: F) -> Option<Ret>where
F: FnOnce(&T) -> Ret,
pub fn is_set(&'static self) -> bool
Auto Trait Implementations
impl<T> !RefUnwindSafe for VisitCache<T>
impl<T> Send for VisitCache<T>
impl<T> Sync for VisitCache<T>
impl<T> Unpin for VisitCache<T>
impl<T> !UnwindSafe for VisitCache<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more