diff --git a/examples/stopwatch/Cargo.toml b/examples/stopwatch/Cargo.toml index 075aa111..9f935951 100644 --- a/examples/stopwatch/Cargo.toml +++ b/examples/stopwatch/Cargo.toml @@ -6,4 +6,4 @@ edition = "2018" publish = false [dependencies] -iced = { path = "../..", features = ["tokio"] } +iced = { path = "../..", features = ["smol"] } 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() } }