Add top-level tests for futures 0.2 integration (#231)

This commit is contained in:
Aaron Turon
2018-03-15 16:38:12 -07:00
committed by Carl Lerche
parent b7f4e337be
commit 7b1306e6c2
6 changed files with 353 additions and 0 deletions
+23
View File
@@ -136,6 +136,9 @@ pub use tokio_executor::{Executor, DefaultExecutor, SpawnError};
use futures::{Future, IntoFuture};
use futures::future::{self, FutureResult};
#[cfg(feature = "unstable-futures")]
use futures2;
/// Return value from the `spawn` function.
///
/// Currently this value doesn't actually provide any functionality. However, it
@@ -205,6 +208,15 @@ where F: Future<Item = (), Error = ()> + 'static + Send
Spawn(())
}
/// Like `spawn`, but compatible with futures 0.2
#[cfg(feature = "unstable-futures")]
pub fn spawn2<F>(f: F) -> Spawn
where F: futures2::Future<Item = (), Error = futures2::Never> + 'static + Send
{
::tokio_executor::spawn2(f);
Spawn(())
}
impl IntoFuture for Spawn {
type Future = FutureResult<(), ()>;
type Item = ();
@@ -214,3 +226,14 @@ impl IntoFuture for Spawn {
future::ok(())
}
}
#[cfg(feature = "unstable-futures")]
impl futures2::IntoFuture for Spawn {
type Future = futures2::future::FutureResult<(), ()>;
type Item = ();
type Error = ();
fn into_future(self) -> Self::Future {
futures2::future::ok(())
}
}