pub fn with_kernel_context<F, R>(ctx: KernelContext, f: F) -> Rwhere
F: FnOnce() -> R,Expand description
Execute a closure with a kernel context set, then clear the context.
This is the preferred way to scope kernel context to a region of code. The context is guaranteed to be cleared even if the closure panics (via drop semantics of the thread-local borrow).