diff options
author | 2021-01-15 18:52:12 +0100 | |
---|---|---|
committer | 2021-01-15 18:52:12 +0100 | |
commit | fd2c96c8e36eb37ea4a53aafe0986b569a4e3753 (patch) | |
tree | 273b2728ecc9dc52636e2c06d5871680a6254813 /futures/src | |
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 'futures/src')
-rw-r--r-- | futures/src/time.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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() } } |