Function task::with_current_task

source ·
pub fn with_current_task<F, R>(function: F) -> Result<R, CurrentTaskNotFound>where
    F: FnOnce(&TaskRef) -> R,
Expand description

Invokes the given function with a reference to the current task.

This is useful to avoid cloning a reference to the current task.

Returns a CurrentTaskNotFound error if the current task cannot be obtained.