diff options
Diffstat (limited to 'futures')
| -rw-r--r-- | futures/Cargo.toml | 2 | ||||
| -rw-r--r-- | futures/src/time.rs | 10 | 
2 files changed, 10 insertions, 2 deletions
| diff --git a/futures/Cargo.toml b/futures/Cargo.toml index c42cc603..c266f705 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -37,7 +37,7 @@ optional = true  features = ["unstable"]  [target.'cfg(not(target_arch = "wasm32"))'.dependencies.smol] -version = "1.0" +version = "1.2"  optional = true  [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/futures/src/time.rs b/futures/src/time.rs index 86b4a4e7..c11942d2 100644 --- a/futures/src/time.rs +++ b/futures/src/time.rs @@ -35,8 +35,16 @@ where          _input: futures::stream::BoxStream<'static, E>,      ) -> futures::stream::BoxStream<'static, Self::Output> {          use futures::stream::StreamExt; +        use std::time::Instant; -        smol::Timer::interval(self.0).boxed() +        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()      }  } | 
