From 9da0a3de54e8e7161d4a3405633bc574ce43eb2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 15 Jan 2021 21:07:37 +0100 Subject: [PATCH] Use `smol::Timer::interval` for `time::Every` --- futures/src/time.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/futures/src/time.rs b/futures/src/time.rs index c11942d2..86b4a4e7 100644 --- a/futures/src/time.rs +++ b/futures/src/time.rs @@ -35,16 +35,8 @@ where _input: futures::stream::BoxStream<'static, E>, ) -> futures::stream::BoxStream<'static, Self::Output> { use futures::stream::StreamExt; - use std::time::Instant; - let duration = self.0; - - futures::stream::unfold(Instant::now(), move |last_tick| async move { - let last_tick = smol::Timer::at(last_tick + duration).await; - - Some((last_tick, last_tick)) - }) - .boxed() + smol::Timer::interval(self.0).boxed() } }