|
|
@ -28,8 +28,6 @@ use crate::task::{Context, Poll};
|
|
|
|
/// #
|
|
|
|
/// #
|
|
|
|
/// # Ok(()) }) }
|
|
|
|
/// # Ok(()) }) }
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
|
|
|
|
|
|
|
#[cfg(any(feature = "unstable", feature = "docs"))]
|
|
|
|
|
|
|
|
pub async fn timeout<F, T>(dur: Duration, f: F) -> Result<T, TimeoutError>
|
|
|
|
pub async fn timeout<F, T>(dur: Duration, f: F) -> Result<T, TimeoutError>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
F: Future<Output = T>,
|
|
|
|
F: Future<Output = T>,
|
|
|
@ -42,8 +40,6 @@ where
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A future that times out after a duration of time.
|
|
|
|
/// A future that times out after a duration of time.
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
|
|
|
#[allow(missing_debug_implementations)]
|
|
|
|
|
|
|
|
struct TimeoutFuture<F> {
|
|
|
|
struct TimeoutFuture<F> {
|
|
|
|
future: F,
|
|
|
|
future: F,
|
|
|
|
delay: Delay,
|
|
|
|
delay: Delay,
|
|
|
@ -69,8 +65,6 @@ impl<F: Future> Future for TimeoutFuture<F> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// An error returned when a future times out.
|
|
|
|
/// An error returned when a future times out.
|
|
|
|
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
|
|
|
|
|
|
|
#[cfg(any(feature = "unstable", feature = "docs"))]
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
|
|
|
pub struct TimeoutError {
|
|
|
|
pub struct TimeoutError {
|
|
|
|
_private: (),
|
|
|
|
_private: (),
|
|
|
|