pub fn from_context<C, F, R>(f: F) -> RExpand description
Provides immutable access to the current context value
§Type Parameters
C- The type of the context value to accessF- The function type that will operate on the contextR- The return type from the function
§Arguments
f- A function that receives an Option<&C> and returns R
§Examples
use with_async_context::from_context;
struct MyContext {
some_value: String
}
let value = from_context(|ctx: Option<&MyContext>| {
ctx.unwrap().some_value.clone()
});