# Function futures::sync::oneshot::spawn [−] [src]

    pub fn spawn<F, E>(future: F, executor: &E) -> SpawnHandle<F::Item, F::Error> where
        F: Future,
        E: Executor<Execute<F>>,

Spawns a `future` onto the instance of `Executor` provided, `executor`, returning a handle representing the completion of the future.

The `SpawnHandle` returned is a future that is a proxy for `future` itself. When `future` completes on `executor` then the `SpawnHandle` will itself be resolved. Internally `SpawnHandle` contains a `oneshot` channel and is thus safe to send across threads.

The `future` will be canceled if the `SpawnHandle` is dropped. If this is not desired then the `SpawnHandle::forget` function can be used to continue running the future to completion.

# Panics

This function will panic if the instance of `Spawn` provided is unable to spawn the `future` provided.

If the provided instance of `Spawn` does not actually run `future` to completion, then the returned handle may panic when polled. Typically this is not a problem, though, as most instances of `Spawn` will run futures to completion.

Note that the returned future will likely panic if the `futures` provided panics. If a future running on an executor panics that typically means that the executor drops the future, which falls into the above case of not running the future to completion essentially.

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)