pub trait ScopeBody<'env>: Send {
type Output: Send;
// Required method
fn run<Spawner: ScopedSpawner<'env>>(
self,
spawner: &Spawner,
) -> Self::Output;
}Expand description
The work ThreadScope::scope runs inside the scope it opens.
This is a trait rather than a closure because run has to
be generic over the spawner: a scope implementation only learns its own
spawner type once it is inside e.g. std::thread::scope, which quantifies
over a lifetime that cannot be named from the outside.
Self and Output are Send so that implementations
of ThreadScope are free to use a scope API that runs the body somewhere
other than the calling thread, such as rayon::scope.
Required Associated Types§
Required Methods§
Sourcefn run<Spawner: ScopedSpawner<'env>>(self, spawner: &Spawner) -> Self::Output
fn run<Spawner: ScopedSpawner<'env>>(self, spawner: &Spawner) -> Self::Output
Called exactly once, with a spawner for the freshly opened scope.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".