From 1c9fa804929d3418292b55d653c489f50eec3805 Mon Sep 17 00:00:00 2001 From: dimi Date: Mon, 13 Jan 2025 11:30:49 +0100 Subject: [PATCH] stm32: impl Display for time::Hertz --- embassy-stm32/src/time.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/embassy-stm32/src/time.rs b/embassy-stm32/src/time.rs index 802ff41ce6..71fe668a98 100644 --- a/embassy-stm32/src/time.rs +++ b/embassy-stm32/src/time.rs @@ -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 {