mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 16:23:10 +00:00
Add from_hz function for Duration.
This commit is contained in:
parent
e1a0df7d46
commit
a4371e9544
@ -81,6 +81,11 @@ impl Duration {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a duration corresponding to the specified Hz.
|
||||
pub const fn from_hz(hz: u64) -> Duration {
|
||||
Duration { ticks: TICK_HZ / hz }
|
||||
}
|
||||
|
||||
/// Adds one Duration to another, returning a new Duration or None in the event of an overflow.
|
||||
pub fn checked_add(self, rhs: Duration) -> Option<Duration> {
|
||||
self.ticks.checked_add(rhs.ticks).map(|ticks| Duration { ticks })
|
||||
|
Loading…
Reference in New Issue
Block a user