Coverage Report

Created: 2025-08-28 07:05

/rust/registry/src/index.crates.io-6f17d22bba15001f/tokio-test-0.4.4/src/lib.rs
Line
Count
Source (jump to first uncovered line)
1
#![warn(
2
    missing_debug_implementations,
3
    missing_docs,
4
    rust_2018_idioms,
5
    unreachable_pub
6
)]
7
#![doc(test(
8
    no_crate_inject,
9
    attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
10
))]
11
12
//! Tokio and Futures based testing utilities
13
14
pub mod io;
15
pub mod stream_mock;
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
27
0
pub fn block_on<F: std::future::Future>(future: F) -> F::Output {
28
    use tokio::runtime;
29
30
0
    let rt = runtime::Builder::new_current_thread()
31
0
        .enable_all()
32
0
        .build()
33
0
        .unwrap();
34
0
35
0
    rt.block_on(future)
36
0
}