[][src]Function task_scope::scope::scope

Important traits for ScopeFuture<Fut, Joiner>
pub fn scope<Fut>(
    inner: Fut
) -> ScopeFuture<impl Future<Output = Fut::Output>, impl Future<Output = ()>> where
    Fut: Future

Create a new task scope.

The task scope runs the given future as its main task. You can spawn subtasks within a scope, and the scope will wait until all tasks complete or it is forcibly canceled. If a scope is created within another scope, it will inherit the cancellation signal from the parent. Thus, when the parent is canceled, the child scope is also canceled.

Returns

The returned future will resolve to:

  • Ok(v) when the main task successfully finishes before a forced cancellation.
  • Err(e) when the main task is canceled forcibly.