# fmt.rs - source
Source of the Rust file `/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/embedded-hal-1.0.0-alpha.1/src/fmt.rs`.
Keywords: rust, rustlang, rust-lang

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18

    //! Implementation of `core::fmt::Write` for the HAL's `serial::Write`.
    //!
    //! TODO write example of usage
    use core::fmt::{Result, Write};

    impl<Word, Error> Write for dyn (crate::serial::Write<Word, Error = Error>)
    where
        Word: From<u8>,
    {
        fn write_str(&mut self, s: &str) -> Result {
            let _ = s
                .as_bytes()
                .into_iter()
                .map(|c| block!(self.try_write(Word::from(*c))))
                .last();
            Ok(())
        }
    }