diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-10-06 22:56:31 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-10-06 23:19:53 +0200 |
| commit | 8730a013c395cf0bf4c2fa8eeb7f138288103039 (patch) | |
| tree | 39eca5fbc4570bd0129c9a291f134de5dab98820 /embassy-time/src | |
| parent | abc8e450f936567ad42cb34b5d2a7941b206aa5d (diff) | |
Rustfmt for edition 2024.
Diffstat (limited to 'embassy-time/src')
| -rw-r--r-- | embassy-time/src/duration.rs | 8 | ||||
| -rw-r--r-- | embassy-time/src/lib.rs | 10 | ||||
| -rw-r--r-- | embassy-time/src/timer.rs | 4 |
3 files changed, 6 insertions, 16 deletions
diff --git a/embassy-time/src/duration.rs b/embassy-time/src/duration.rs index b3ea0468d..b2bfd6de9 100644 --- a/embassy-time/src/duration.rs +++ b/embassy-time/src/duration.rs | |||
| @@ -175,13 +175,7 @@ impl Duration { | |||
| 175 | /// NOTE: Giving this function a hz >= the TICK_HZ of your platform will clamp the Duration to 1 | 175 | /// NOTE: Giving this function a hz >= the TICK_HZ of your platform will clamp the Duration to 1 |
| 176 | /// tick. Doing so will not deadlock, but will certainly not produce the desired output. | 176 | /// tick. Doing so will not deadlock, but will certainly not produce the desired output. |
| 177 | pub const fn from_hz(hz: u64) -> Duration { | 177 | pub const fn from_hz(hz: u64) -> Duration { |
| 178 | let ticks = { | 178 | let ticks = { if hz >= TICK_HZ { 1 } else { (TICK_HZ + hz / 2) / hz } }; |
| 179 | if hz >= TICK_HZ { | ||
| 180 | 1 | ||
| 181 | } else { | ||
| 182 | (TICK_HZ + hz / 2) / hz | ||
| 183 | } | ||
| 184 | }; | ||
| 185 | Duration { ticks } | 179 | Duration { ticks } |
| 186 | } | 180 | } |
| 187 | 181 | ||
diff --git a/embassy-time/src/lib.rs b/embassy-time/src/lib.rs index 5a511a0bd..e375fe93e 100644 --- a/embassy-time/src/lib.rs +++ b/embassy-time/src/lib.rs | |||
| @@ -28,18 +28,14 @@ mod driver_std; | |||
| 28 | #[cfg(feature = "wasm")] | 28 | #[cfg(feature = "wasm")] |
| 29 | mod driver_wasm; | 29 | mod driver_wasm; |
| 30 | 30 | ||
| 31 | pub use delay::{block_for, Delay}; | 31 | pub use delay::{Delay, block_for}; |
| 32 | pub use duration::Duration; | 32 | pub use duration::Duration; |
| 33 | pub use embassy_time_driver::TICK_HZ; | 33 | pub use embassy_time_driver::TICK_HZ; |
| 34 | pub use instant::Instant; | 34 | pub use instant::Instant; |
| 35 | pub use timer::{with_deadline, with_timeout, Ticker, TimeoutError, Timer, WithTimeout}; | 35 | pub use timer::{Ticker, TimeoutError, Timer, WithTimeout, with_deadline, with_timeout}; |
| 36 | 36 | ||
| 37 | const fn gcd(a: u64, b: u64) -> u64 { | 37 | const fn gcd(a: u64, b: u64) -> u64 { |
| 38 | if b == 0 { | 38 | if b == 0 { a } else { gcd(b, a % b) } |
| 39 | a | ||
| 40 | } else { | ||
| 41 | gcd(b, a % b) | ||
| 42 | } | ||
| 43 | } | 39 | } |
| 44 | 40 | ||
| 45 | pub(crate) const GCD_1K: u64 = gcd(TICK_HZ, 1_000); | 41 | pub(crate) const GCD_1K: u64 = gcd(TICK_HZ, 1_000); |
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs index fcf79f58e..2f5967c63 100644 --- a/embassy-time/src/timer.rs +++ b/embassy-time/src/timer.rs | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | use core::future::{poll_fn, Future}; | 1 | use core::future::{Future, poll_fn}; |
| 2 | use core::pin::Pin; | 2 | use core::pin::Pin; |
| 3 | use core::task::{Context, Poll}; | 3 | use core::task::{Context, Poll}; |
| 4 | 4 | ||
| 5 | use futures_core::stream::FusedStream; | ||
| 6 | use futures_core::Stream; | 5 | use futures_core::Stream; |
| 6 | use futures_core::stream::FusedStream; | ||
| 7 | 7 | ||
| 8 | use crate::{Duration, Instant}; | 8 | use crate::{Duration, Instant}; |
| 9 | 9 | ||
