Skip to content

Commit 73e0773

Browse files
90-008hecrj
authored andcommitted
Remove async-stream dependency
We leverage `stream::unfold` instead.
1 parent f8aef03 commit 73e0773

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

examples/game_of_life/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ publish = false
77

88
[dependencies]
99
iced = { path = "../..", features = ["canvas", "tokio", "debug"] }
10-
tokio = { version = "0.3", features = ["sync"] }
10+
tokio = { version = "1.0", features = ["sync"] }
1111
itertools = "0.9"
1212
rustc-hash = "1.1"

futures/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ optional = true
2626
features = ["rt-core", "rt-threaded", "time", "stream"]
2727

2828
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
29-
version = "0.3"
29+
package = "tokio"
30+
version = "1.0"
3031
optional = true
31-
features = ["rt-multi-thread", "time", "stream"]
32+
features = ["rt", "rt-multi-thread", "time"]
3233

3334
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-std]
3435
version = "1.0"

futures/src/time.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,20 @@ where
6767

6868
let start = tokio::time::Instant::now() + self.0;
6969

70-
tokio::time::interval_at(start, self.0)
71-
.map(|_| std::time::Instant::now())
72-
.boxed()
70+
let stream = {
71+
#[cfg(feature = "tokio")]
72+
{
73+
futures::stream::unfold(
74+
tokio::time::interval_at(start, self.0),
75+
|mut interval| async move {
76+
Some((interval.tick().await, interval))
77+
},
78+
)
79+
}
80+
#[cfg(feature = "tokio_old")]
81+
tokio::time::interval_at(start, self.0)
82+
};
83+
84+
stream.map(|_| std::time::Instant::now()).boxed()
7385
}
7486
}

0 commit comments

Comments
 (0)