pub struct GlobalContextGuard<C: 'static> { /* private fields */ }Expand description
Guard returned by set_global_context.
When dropped, the previously installed context value (if any) is restored.
§Examples
use ad_tensors_rs::{set_global_context, with_global_context};
let _guard = set_global_context::<u32>(7);
let v = with_global_context::<u32, _>(|ctx| Ok(*ctx)).unwrap();
assert_eq!(v, 7);Trait Implementations§
Source§impl<C: 'static> Drop for GlobalContextGuard<C>
impl<C: 'static> Drop for GlobalContextGuard<C>
Auto Trait Implementations§
impl<C> !RefUnwindSafe for GlobalContextGuard<C>
impl<C> !Send for GlobalContextGuard<C>
impl<C> !Sync for GlobalContextGuard<C>
impl<C> !UnwindSafe for GlobalContextGuard<C>
impl<C> Freeze for GlobalContextGuard<C>
impl<C> Unpin for GlobalContextGuard<C>where
C: Unpin,
impl<C> UnsafeUnpin for GlobalContextGuard<C>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more