Files
tokio/tokio-test/src/lib.rs
T

39 lines
1011 B
Rust
Raw Normal View History

#![doc(html_root_url = "https://docs.rs/tokio-test/0.3.0")]
#![warn(
2019-05-14 10:27:36 -07:00
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
unreachable_pub
2019-05-14 10:27:36 -07:00
)]
2019-09-13 06:46:19 -10:00
#![deny(intra_doc_link_resolution_failure)]
2019-09-19 15:50:12 +09:00
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]
2019-04-23 23:17:57 -04:00
//! Tokio and Futures based testing utilites
2019-07-11 14:41:37 -07:00
pub mod io;
2019-04-23 23:17:57 -04:00
mod macros;
pub mod task;
2019-05-03 20:43:40 -07:00
/// Runs the provided future, blocking the current thread until the
/// future completes.
///
/// For more information, see the documentation for
/// [`tokio::runtime::current_thread::Runtime::block_on`][runtime-block-on].
///
/// [runtime-block-on]: https://docs.rs/tokio/0.2.0-alpha.2/tokio/runtime/current_thread/struct.Runtime.html#method.block_on
pub fn block_on<F: std::future::Future>(future: F) -> F::Output {
use tokio::runtime;
let mut rt = runtime::Builder::new()
.basic_scheduler()
.enable_all()
.build()
.unwrap();
rt.block_on(future)
2019-05-03 20:43:40 -07:00
}