1 2 3 4 5 6 7 8 9 10
use std::future::Future;
use std::time::Duration;
use tokio::time::Timeout;
pub trait FutureTimeoutExt: Future + Sized {
fn timeout(self, timeout: Duration) -> Timeout<Self> {
tokio::time::timeout(timeout, self)
}
}
impl<T> FutureTimeoutExt for T where T: Future {}