diff options
| author | 2021-01-15 18:52:12 +0100 | |
|---|---|---|
| committer | 2021-01-15 18:52:12 +0100 | |
| commit | fd2c96c8e36eb37ea4a53aafe0986b569a4e3753 (patch) | |
| tree | 273b2728ecc9dc52636e2c06d5871680a6254813 /futures | |
| parent | bcc54b0831d3794e2105f591db4c325615d35041 (diff) | |
| download | iced-fd2c96c8e36eb37ea4a53aafe0986b569a4e3753.tar.gz iced-fd2c96c8e36eb37ea4a53aafe0986b569a4e3753.tar.bz2 iced-fd2c96c8e36eb37ea4a53aafe0986b569a4e3753.zip | |
Fix `time::Every` implementation for `smol` runtime
Diffstat (limited to '')
| -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()      }  } | 
