Skip to content

Instantly share code, notes, and snippets.

@narodnik
Created July 5, 2020 10:34
Show Gist options
  • Save narodnik/6ddfa64cd2cc10b2dcf60623cd49ddeb to your computer and use it in GitHub Desktop.
Save narodnik/6ddfa64cd2cc10b2dcf60623cd49ddeb to your computer and use it in GitHub Desktop.
impl<T: Send + 'static> Task<T> {
/// Spawns a future onto the work-stealing executor.
///
/// This future may be stolen and polled by any thread calling [`run()`].
///
/// # Examples
///
/// ```
/// use smol::Task;
///
/// # smol::run(async {
/// let task = Task::spawn(async { 1 + 2 });
/// assert_eq!(task.await, 3);
/// # });
/// ```
///
/// [`run()`]: `crate::run()`
pub fn spawn(future: impl Future<Output = T> + Send + 'static) -> Task<T> {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment