2019-05-14 10:27:36 -07:00
|
|
|
#![deny(warnings, rust_2018_idioms)]
|
2019-06-24 12:34:30 -07:00
|
|
|
#![feature(await_macro, async_await)]
|
2018-02-21 07:42:22 -08:00
|
|
|
|
2019-05-14 10:27:36 -07:00
|
|
|
use tokio_executor::{self, DefaultExecutor};
|
2018-02-21 07:42:22 -08:00
|
|
|
|
2019-06-24 12:34:30 -07:00
|
|
|
use std::future::Future;
|
|
|
|
|
use std::pin::Pin;
|
|
|
|
|
|
2018-09-17 22:23:48 -07:00
|
|
|
mod out_of_executor_context {
|
|
|
|
|
use super::*;
|
2019-03-21 14:30:18 -07:00
|
|
|
use tokio_executor::Executor;
|
2018-09-17 22:23:48 -07:00
|
|
|
|
|
|
|
|
fn test<F, E>(spawn: F)
|
|
|
|
|
where
|
2019-06-24 12:34:30 -07:00
|
|
|
F: Fn(Pin<Box<dyn Future<Output = ()> + Send>>) -> Result<(), E>,
|
2018-09-17 22:23:48 -07:00
|
|
|
{
|
2019-06-24 12:34:30 -07:00
|
|
|
let res = spawn(Box::pin(async {}));
|
2018-09-17 22:23:48 -07:00
|
|
|
assert!(res.is_err());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn spawn() {
|
|
|
|
|
test(|f| DefaultExecutor::current().spawn(f));
|
|
|
|
|
}
|
2018-02-21 07:42:22 -08:00
|
|
|
}
|