1 #![warn(
2     missing_debug_implementations,
3     missing_docs,
4     rust_2018_idioms,
5     unreachable_pub
6 )]
7 #![cfg_attr(docsrs, deny(broken_intra_doc_links))]
8 #![doc(test(
9     no_crate_inject,
10     attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
11 ))]
12 
13 //! Tokio and Futures based testing utilites
14 
15 pub mod io;
16 
17 mod macros;
18 pub mod task;
19 
20 /// Runs the provided future, blocking the current thread until the
21 /// future completes.
22 ///
23 /// For more information, see the documentation for
24 /// [`tokio::runtime::Runtime::block_on`][runtime-block-on].
25 ///
26 /// [runtime-block-on]: https://docs.rs/tokio/1.3.0/tokio/runtime/struct.Runtime.html#method.block_on
block_on<F: std::future::Future>(future: F) -> F::Output27 pub fn block_on<F: std::future::Future>(future: F) -> F::Output {
28     use tokio::runtime;
29 
30     let rt = runtime::Builder::new_current_thread()
31         .enable_all()
32         .build()
33         .unwrap();
34 
35     rt.block_on(future)
36 }
37