pub fn delay_task<F>(fut: F, dur: Duration) -> task::JoinHandle<Result<()>>
where
	F: future::Future<Output = Result<()>> + Send + 'static,
{
	task::spawn(async move {
		let forever = future::pending::<()>();
		// ignore the TimeOut error because forever is staying forever in pending state
		let _ = future::timeout(dur, forever).await;
		fut.await?;
		Ok::<(), anyhow::Error>(())
	})
}
/// delay a future by a duration
delay a future by a duration
delay a future by a duration
pub fn delay_task<F>(fut: F, dur: Duration) -> task::JoinHandle<Result<()>>
where
	F: future::Future<Output = Result<()>> + Send + 'static,
{
	task::spawn(async move {
		let forever = future::pending::<()>();
		// ignore the TimeOut error because forever is staying forever in pending state
		let _ = future::timeout(dur, forever).await;
		fut.await?;
		Ok::<(), anyhow::Error>(())
	})
}
pub fn delay_task < F > ( fut : F , dur : Duration ) -> task :: JoinHandle < Result < ( ) > > where F : future :: Future < Output = Result < ( ) > > + Send + ' static , { task :: spawn ( async move { let forever = future :: pending :: < ( ) > ( ) ; // ignore the TimeOut error because forever is staying forever in pending state let _ = future :: timeout ( dur , forever ) . await ; fut . await ? ; Ok :: < ( ) , anyhow :: Error > ( ( ) ) } ) }
delay a future by a duration
delay a future by a duration
fut
F
dur
Duration
fut
F
dur
Duration