futures_util::compat

Trait Executor01CompatExt

source
pub trait Executor01CompatExt:
    Executor01<Executor01Future>
    + Clone
    + Send
    + 'static {
    // Required method
    fn compat(self) -> Executor01As03<Self>
       where Self: Sized;
}
Available on crate feature compat only.
Expand description

Extension trait for futures 0.1 Executor.

Required Methods§

source

fn compat(self) -> Executor01As03<Self>
where Self: Sized,

Converts a futures 0.1 Executor into a futures 0.3 Spawn.

use futures::task::SpawnExt;
use futures::future::{FutureExt, TryFutureExt};
use futures_util::compat::Executor01CompatExt;
use tokio::executor::DefaultExecutor;


let spawner = DefaultExecutor::current().compat();
let future03 = async move {
    println!("Running on the pool");
    spawner.spawn(async {
        println!("Spawned!");
    }).unwrap();
};

let future01 = future03.unit_error().boxed().compat();

tokio::run(future01);

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Ex> Executor01CompatExt for Ex
where Ex: Executor01<Executor01Future> + Clone + Send + 'static,