Struct Scope

struct Scope<'scope, 'env: 'scope> { ... }

A scope to spawn scoped threads in.

See scope for details.

Implementations

impl<'scope, 'env> Scope<'scope, 'env>

fn spawn<F, T>(self: &'scope Self, f: F) -> ScopedJoinHandle<'scope, T>
where
    F: FnOnce() -> T + Send + 'scope,
    T: Send + 'scope

Spawns a new thread within a scope, returning a ScopedJoinHandle for it.

Unlike non-scoped threads, threads spawned with this function may borrow non-'static data from the outside the scope. See scope for details.

The join handle provides a join method that can be used to join the spawned thread. If the spawned thread panics, join will return an Err containing the panic payload.

If the join handle is dropped, the spawned thread will be implicitly joined at the end of the scope. In that case, if the spawned thread panics, scope will panic after all threads are joined.

This function creates a thread with the default parameters of Builder. To specify the new thread's stack size or the name, use Builder::spawn_scoped.

Panics

Panics if the OS fails to create a thread; use Builder::spawn_scoped to recover from such errors.

impl Debug for Scope<'_, '_>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<'scope, 'env> Freeze for Scope<'scope, 'env>

impl<'scope, 'env> RefUnwindSafe for Scope<'scope, 'env>

impl<'scope, 'env> Send for Scope<'scope, 'env>

impl<'scope, 'env> Sync for Scope<'scope, 'env>

impl<'scope, 'env> Unpin for Scope<'scope, 'env>

impl<'scope, 'env> UnsafeUnpin for Scope<'scope, 'env>

impl<'scope, 'env> UnwindSafe for Scope<'scope, 'env>

impl<T> Any for Scope<'scope, 'env>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Scope<'scope, 'env>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Scope<'scope, 'env>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for Scope<'scope, 'env>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Scope<'scope, 'env>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Scope<'scope, 'env>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Scope<'scope, 'env>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>