commit
084b64053a
1 changed files with 13 additions and 0 deletions
|
@ -22,6 +22,10 @@ impl Duration {
|
|||
self.ticks * 1000 / TICKS_PER_SECOND
|
||||
}
|
||||
|
||||
pub const fn as_micros(&self) -> u64 {
|
||||
self.ticks * 1_000_000 / TICKS_PER_SECOND
|
||||
}
|
||||
|
||||
pub const fn from_ticks(ticks: u64) -> Duration {
|
||||
Duration { ticks }
|
||||
}
|
||||
|
@ -38,6 +42,15 @@ impl Duration {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
NOTE: us delays may not be as accurate
|
||||
*/
|
||||
pub const fn from_micros(millis: u64) -> Duration {
|
||||
Duration {
|
||||
ticks: millis * TICKS_PER_SECOND / 1_000_000,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn checked_add(self, rhs: Duration) -> Option<Duration> {
|
||||
self.ticks
|
||||
.checked_add(rhs.ticks)
|
||||
|
|
Loading…
Reference in a new issue