From cde182d44fe4dcaa3d206ceb5cf093f74de6c85e Mon Sep 17 00:00:00 2001 From: Saiyed Shizain Date: Sun, 18 Jan 2026 17:34:15 +0530 Subject: add a simple countdown logic --- src/pomo.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/pomo.rs (limited to 'src/pomo.rs') diff --git a/src/pomo.rs b/src/pomo.rs new file mode 100644 index 0000000..a5042ef --- /dev/null +++ b/src/pomo.rs @@ -0,0 +1,27 @@ +use std::{ thread, time::Duration }; + +pub struct Pomo { + pub time_remaining: Duration, +} + +impl Pomo { + pub fn new() -> Self { + Self { + time_remaining: Duration::from_secs(25 * 60), + } + } + + pub fn tick(&mut self) { + self.time_remaining -= Duration::from_secs(1); + } + + pub fn run(&mut self) { + self.time_remaining = Duration::from_secs(10); + while self.time_remaining > Duration::from_secs(0) { + println!("{}", self.time_remaining.as_secs()); + self.tick(); + thread::sleep(Duration::from_secs(1)); + } + println!("Done"); + } +} -- cgit v1.2.3