pub fn with_current_task_and_value<F, R, T>(
    function: F,
    value: T
) -> Result<R, T>where
    F: FnOnce(&TaskRef, T) -> R,
Expand description

Similar to with_current_task(), but also accepts a value that is passed to the given function or returned in the case of an error.

This is useful for two reasons:

  1. Like with_current_task(), it avoids cloning a reference to the current task.
  2. It allows the value to be returned upon an error, instead of the behavior in with_current_task() that unconditionally takes ownership of the value without any way to recover ownership of that value.

Returns an Err containing the value if the current task cannot be obtained.