pub fn from_context_mut<C, F, R>(f: F) -> RExpand description
Provides mutable 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<&mut C> and returns R
§Examples
use with_async_context::from_context_mut;
struct MyContext {
counter: i32
}
from_context_mut(|ctx: Option<&mut MyContext>| {
if let Some(ctx) = ctx {
ctx.counter += 1;
}
});