pub fn set_global_context<C: 'static>(ctx: C) -> GlobalContextGuard<C>Expand description
Sets a thread-local global context for type C.
Returns a guard that restores the previous context on drop.
ยงExamples
use ad_tensors_rs::{set_global_context, with_global_context};
let guard = set_global_context::<usize>(123);
let value = with_global_context::<usize, _>(|ctx| Ok(*ctx)).unwrap();
assert_eq!(value, 123);
drop(guard);