blob: a5042ef1cdc64ce01ddf904de275b0c807d9acaf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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");
}
}
|