devela/work/async/
ext.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// devela::work::async::ext
//
//!
//

#[cfg(feature = "std")]
use super::future_block;
use super::Future;

impl<F: Future> ExtFuture for F {}

/// Extension trait providing additional methods for [`Future`]s.
pub trait ExtFuture: Future {
    /// Blocks the thread until the future is ready.
    ///
    /// See also the [`future_block`] function.
    ///
    /// # Example
    /// ```
    /// use devela::ExtFuture as _;
    ///
    /// let future = async {};
    /// let result = future.block_on();
    /// ```
    #[rustfmt::skip]
    #[cfg(feature = "std")]
    #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "std")))]
    fn block_on(self) -> Self::Output where Self: Sized { future_block(self) }
}