Merge pull request #3765 from dimpolo/hertz-display

stm32: impl Display for time::Hertz
This commit is contained in:
Dario Nieuwenhuis 2025-01-22 00:34:40 +01:00 committed by GitHub
commit 010d4622f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
//! Time units
use core::fmt::Display;
use core::ops::{Div, Mul};
/// Hertz
@ -7,6 +8,12 @@ use core::ops::{Div, Mul};
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Hertz(pub u32);
impl Display for Hertz {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{} Hz", self.0)
}
}
impl Hertz {
/// Create a `Hertz` from the given hertz.
pub const fn hz(hertz: u32) -> Self {