on master help sign in
Instant is more suitable than SystemTime for spinners
commit1bcb624ae65273cad13a3a65c567e0850fb0c9ed authorBlaž Hrastnik <blaz@mxxn.io> dateTue 8 Feb 2022, 18:48 (5 years ago) parentf88c077
1 file changed+4−5
helix-term/src/ui/spinner.rs+4−5
helix-term/src/ui/spinner.rs+4−5
@@ -1,4 +1,4 @@
1−use std::{collections::HashMap, time::SystemTime};
1+use std::{collections::HashMap, time::Instant};
22
33#[derive(Default, Debug)]
44pub struct ProgressSpinners {
@@ -25,7 +25,7 @@ impl Default for Spinner {
2525pub struct Spinner {
2626 frames: Vec<&'static str>,
2727 count: usize,
28− start: Option<SystemTime>,
28+ start: Option<Instant>,
2929 interval: u64,
3030}
3131
@@ -50,14 +50,13 @@ impl Spinner {
5050 }
5151
5252 pub fn start(&mut self) {
53− self.start = Some(SystemTime::now());
53+ self.start = Some(Instant::now());
5454 }
5555
5656 pub fn frame(&self) -> Option<&str> {
5757 let idx = (self
5858 .start
59− .map(|time| SystemTime::now().duration_since(time))?
60− .ok()?
59+ .map(|time| Instant::now().duration_since(time))?
6160 .as_millis()
6261 / self.interval as u128) as usize
6362 % self.count;