mirror of
https://github.com/async-rs/async-std.git
synced 2025-01-16 10:49:55 +00:00
stabilize future::timeout (#335)
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
parent
49faea2023
commit
00d936488b
2 changed files with 2 additions and 8 deletions
|
@ -54,18 +54,18 @@ pub use future::Future;
|
|||
pub use pending::pending;
|
||||
pub use poll_fn::poll_fn;
|
||||
pub use ready::ready;
|
||||
pub use timeout::{timeout, TimeoutError};
|
||||
|
||||
pub(crate) mod future;
|
||||
mod pending;
|
||||
mod poll_fn;
|
||||
mod ready;
|
||||
mod timeout;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(any(feature = "unstable", feature = "docs"))] {
|
||||
mod into_future;
|
||||
mod timeout;
|
||||
|
||||
pub use into_future::IntoFuture;
|
||||
pub use timeout::{timeout, TimeoutError};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@ use crate::task::{Context, Poll};
|
|||
/// #
|
||||
/// # 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>
|
||||
where
|
||||
F: Future<Output = T>,
|
||||
|
@ -42,8 +40,6 @@ where
|
|||
}
|
||||
|
||||
/// A future that times out after a duration of time.
|
||||
#[doc(hidden)]
|
||||
#[allow(missing_debug_implementations)]
|
||||
struct TimeoutFuture<F> {
|
||||
future: F,
|
||||
delay: Delay,
|
||||
|
@ -69,8 +65,6 @@ impl<F: Future> Future for TimeoutFuture<F> {
|
|||
}
|
||||
|
||||
/// 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)]
|
||||
pub struct TimeoutError {
|
||||
_private: (),
|
||||
|
|
Loading…
Reference in a new issue