summaryrefslogtreecommitdiffstats
path: root/examples/game_of_life
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2025-01-24 18:59:44 +0100
committerLibravatar GitHub <noreply@github.com>2025-01-24 18:59:44 +0100
commit5eedf5798c0fcd92cfd3f304ce9454bb6c274f09 (patch)
tree0d8d28ef8c062ea1a1651b77531ed091dfe5e561 /examples/game_of_life
parent654c4b37148bda655f0c6676845d2b4ead801f40 (diff)
parent3d893ae01b64eb51b2f5854949c694090118e052 (diff)
downloadiced-5eedf5798c0fcd92cfd3f304ce9454bb6c274f09.tar.gz
iced-5eedf5798c0fcd92cfd3f304ce9454bb6c274f09.tar.bz2
iced-5eedf5798c0fcd92cfd3f304ce9454bb6c274f09.zip
Merge pull request #2747 from iced-rs/time-repeat-subscription
Implement `time::repeat` and simplify `Subscription::run_with`
Diffstat (limited to 'examples/game_of_life')
-rw-r--r--examples/game_of_life/src/main.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs
index 7a7224d5..1008e477 100644
--- a/examples/game_of_life/src/main.rs
+++ b/examples/game_of_life/src/main.rs
@@ -5,12 +5,11 @@ mod preset;
use grid::Grid;
use preset::Preset;
-use iced::time;
+use iced::time::{self, milliseconds};
use iced::widget::{
button, checkbox, column, container, pick_list, row, slider, text,
};
use iced::{Center, Element, Fill, Subscription, Task, Theme};
-use std::time::Duration;
pub fn main() -> iced::Result {
tracing_subscriber::fmt::init();
@@ -112,7 +111,7 @@ impl GameOfLife {
fn subscription(&self) -> Subscription<Message> {
if self.is_playing {
- time::every(Duration::from_millis(1000 / self.speed as u64))
+ time::every(milliseconds(1000 / self.speed as u64))
.map(|_| Message::Tick)
} else {
Subscription::none()
@@ -191,6 +190,7 @@ mod grid {
use crate::Preset;
use iced::alignment;
use iced::mouse;
+ use iced::time::{Duration, Instant};
use iced::touch;
use iced::widget::canvas;
use iced::widget::canvas::{
@@ -202,7 +202,6 @@ mod grid {
use rustc_hash::{FxHashMap, FxHashSet};
use std::future::Future;
use std::ops::RangeInclusive;
- use std::time::{Duration, Instant};
pub struct Grid {
state: State,