pub fn with_default_runtime<R>(
f: impl FnOnce(&mut RuntimeContext) -> Result<R>,
) -> Result<R>Expand description
Runs f with the default runtime context.
Returns crate::Error::RuntimeNotConfigured when runtime is not
configured.
ยงExamples
use tenferro::{set_default_runtime, with_default_runtime, RuntimeContext};
use tenferro_prims::CpuContext;
let _guard = set_default_runtime(RuntimeContext::Cpu(CpuContext::new(1)));
let name = with_default_runtime(|rt| Ok(rt.name())).unwrap();
assert_eq!(name, "cpu");