mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-10-02 14:44:32 +00:00
Merge pull request #3765 from dimpolo/hertz-display
stm32: impl Display for time::Hertz
This commit is contained in:
commit
010d4622f9
@ -1,5 +1,6 @@
|
|||||||
//! Time units
|
//! Time units
|
||||||
|
|
||||||
|
use core::fmt::Display;
|
||||||
use core::ops::{Div, Mul};
|
use core::ops::{Div, Mul};
|
||||||
|
|
||||||
/// Hertz
|
/// Hertz
|
||||||
@ -7,6 +8,12 @@ use core::ops::{Div, Mul};
|
|||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
pub struct Hertz(pub u32);
|
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 {
|
impl Hertz {
|
||||||
/// Create a `Hertz` from the given hertz.
|
/// Create a `Hertz` from the given hertz.
|
||||||
pub const fn hz(hertz: u32) -> Self {
|
pub const fn hz(hertz: u32) -> Self {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user