pub fn try_with_timeout<F: Future>(
timeout: impl Into<Duration>,
fut: F,
) -> Option<TimeoutFuture<F>>Expand description
Tries to run 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.
This is a panic-free version of with_timeout.