Skip to content

Commit 010d462

Browse files
authored
Merge pull request #3765 from dimpolo/hertz-display
stm32: impl Display for time::Hertz
2 parents 1d8ef6f + 1c9fa80 commit 010d462

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

embassy-stm32/src/time.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
//! Time units
22
3+
use core::fmt::Display;
34
use core::ops::{Div, Mul};
45

56
/// Hertz
67
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug)]
78
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
89
pub struct Hertz(pub u32);
910

11+
impl Display for Hertz {
12+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
13+
write!(f, "{} Hz", self.0)
14+
}
15+
}
16+
1017
impl Hertz {
1118
/// Create a `Hertz` from the given hertz.
1219
pub const fn hz(hertz: u32) -> Self {

0 commit comments

Comments
 (0)