pub fn try_with_global_context<C: 'static, R>(
f: impl FnOnce(&mut C) -> Result<R>,
) -> Result<Option<R>>Expand description
Like with_global_context but returns Ok(None) when context is missing.
ยงExamples
use ad_tensors_rs::try_with_global_context;
let value = try_with_global_context::<u64, _>(|ctx| Ok(*ctx)).unwrap();
assert_eq!(value, None);