pub fn with_timeout<F: Future>(
timeout: impl Into<Duration>,
fut: F,
) -> TimeoutFuture<F>Expand description
Runs a given future with a timeout.
If the future completes before the timeout, its output is returned. Otherwise, on timeout,
work on the future is stopped (poll is no longer called), the future is dropped and Err(TimeoutError) is returned.