diff options
author | Blaž Hrastnik | 2022-02-08 09:48:19 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-02-10 02:12:47 +0000 |
commit | 1bcb624ae65273cad13a3a65c567e0850fb0c9ed (patch) | |
tree | f3642cddcc4a6ded3610f3690707b5495b31ada9 /helix-term/src/ui | |
parent | f88c077f992bbfc5ea3623441a9e2b2a0e9ca2b2 (diff) |
Instant is more suitable than SystemTime for spinners
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r-- | helix-term/src/ui/spinner.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/helix-term/src/ui/spinner.rs b/helix-term/src/ui/spinner.rs index e8a43b48..68965469 100644 --- a/helix-term/src/ui/spinner.rs +++ b/helix-term/src/ui/spinner.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, time::SystemTime}; +use std::{collections::HashMap, time::Instant}; #[derive(Default, Debug)] pub struct ProgressSpinners { @@ -25,7 +25,7 @@ impl Default for Spinner { pub struct Spinner { frames: Vec<&'static str>, count: usize, - start: Option<SystemTime>, + start: Option<Instant>, interval: u64, } @@ -50,14 +50,13 @@ impl Spinner { } pub fn start(&mut self) { - self.start = Some(SystemTime::now()); + self.start = Some(Instant::now()); } pub fn frame(&self) -> Option<&str> { let idx = (self .start - .map(|time| SystemTime::now().duration_since(time))? - .ok()? + .map(|time| Instant::now().duration_since(time))? .as_millis() / self.interval as u128) as usize % self.count; |