tokio 0.1.22

An event-driven, non-blocking I/O platform for writing asynchronous I/O backed applications.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use super::Runtime;
use std::future::Future;

impl Runtime {
    /// Like `block_on`, but takes an `async` block
    pub fn block_on_async<F>(&mut self, future: F) -> F::Output
    where
        F: Future + Send + 'static,
        F::Output: Send + 'static,
    {
        use tokio_futures::compat;

        match self.block_on(compat::infallible_into_01(future)) {
            Ok(v) => v,
            Err(_) => unreachable!(),
        }
    }
}