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

36 lines
853 B
Rust
Raw Normal View History

#![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-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
2021-07-01 02:06:56 +09:00
//! Tokio and Futures based testing utilities
2019-04-23 23:17:57 -04:00
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::Runtime::block_on`][runtime-block-on].
///
/// [runtime-block-on]: https://docs.rs/tokio/1.3.0/tokio/runtime/struct.Runtime.html#method.block_on
pub fn block_on<F: std::future::Future>(future: F) -> F::Output {
use tokio::runtime;
let rt = runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
rt.block_on(future)
2019-05-03 20:43:40 -07:00
}