pub async fn timeout<F>(
duration: Duration,
future: F,
) -> Result<<F as Future>::Output, Elapsed>where
F: Future,Expand description
Await future until duration elapses, then drop it and return Elapsed.
The future is polled first, even for zero duration; cancellation runs only
its drop cleanup. Uses a native timer thread or browser setTimeout, without
requiring an executor timer or a feature flag.
ยงPanics
May panic if the timer cannot represent the deadline for duration.