add Timer::restart

This commit is contained in:
Tove 2025-12-17 16:46:19 +01:00
parent 864e71da28
commit 4b9026fda7
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
3 changed files with 7 additions and 2 deletions

2
Cargo.lock generated
View file

@ -4,4 +4,4 @@ version = 4
[[package]]
name = "microlock"
version = "0.3.0"
version = "0.3.1"

View file

@ -3,7 +3,7 @@ name = "microlock"
description = "A crate for waiting: Small locks and other timing things!"
license = "MIT"
repository = "https://git.tudbut.de/tudbut/microlock"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
[dependencies]

View file

@ -118,6 +118,11 @@ impl Timer {
pub fn time_elapsed(&self) -> Duration {
self.0.unwrap_or_else(Instant::now).elapsed()
}
pub fn restart(&mut self) {
self.0 = Some(Instant::now());
}
}
/// Something with a timeout.