Correct descriptions of Duration

This commit is contained in:
Joshua Salzedo 2021-03-21 17:11:30 -07:00
parent 7988b78107
commit 42be860446
No known key found for this signature in database
GPG Key ID: C3D0EB484493B731

View File

@ -5,7 +5,7 @@ use super::TICKS_PER_SECOND;
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
/// Represents the difference between [Instant::now()](struct.Instant.html#method.now) and some other Instant /// Represents the difference between two [Instant](struct.Instant.html)s
pub struct Duration { pub struct Duration {
pub(crate) ticks: u64, pub(crate) ticks: u64,
} }
@ -68,14 +68,14 @@ impl Duration {
.map(|ticks| Duration { ticks }) .map(|ticks| Duration { ticks })
} }
/// Multiplies one Duration to another, returning a new Duration or None in the event of an overflow. /// Multiplies one Duration by a scalar u32, returning a new Duration or None in the event of an overflow.
pub fn checked_mul(self, rhs: u32) -> Option<Duration> { pub fn checked_mul(self, rhs: u32) -> Option<Duration> {
self.ticks self.ticks
.checked_mul(rhs as _) .checked_mul(rhs as _)
.map(|ticks| Duration { ticks }) .map(|ticks| Duration { ticks })
} }
/// Divides one Duration against another, returning a new Duration or None in the event of an overflow. /// Divides one Duration a scalar u32, returning a new Duration or None in the event of an overflow.
pub fn checked_div(self, rhs: u32) -> Option<Duration> { pub fn checked_div(self, rhs: u32) -> Option<Duration> {
self.ticks self.ticks
.checked_div(rhs as _) .checked_div(rhs as _)