add Timer::restart
This commit is contained in:
parent
864e71da28
commit
4b9026fda7
3 changed files with 7 additions and 2 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -4,4 +4,4 @@ version = 4
|
|||
|
||||
[[package]]
|
||||
name = "microlock"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue