Skip to content

Commit d14d6cd

Browse files
thenewwazooBrandon Matthews
authored and
Brandon Matthews
committed
impl Write for serial::Write for all serial Words
1 parent 98a6fb8 commit d14d6cd

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/fmt.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Implementation of `core::fmt::Write` for the HAL's `serial::Write`.
2+
//!
3+
//! TODO write example of usage
4+
use core::fmt::{Result, Write};
5+
6+
impl<Word, Error> Write for ::serial::Write<Word, Error=Error>
7+
where
8+
Word: From<u8>,
9+
{
10+
fn write_str(&mut self, s: &str) -> Result {
11+
let _ = s.as_bytes()
12+
.into_iter()
13+
.map(|c| block!(self.write(Word::from(*c))))
14+
.last();
15+
Ok(())
16+
}
17+
}

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ extern crate void;
692692
pub mod adc;
693693
pub mod blocking;
694694
pub mod digital;
695+
pub mod fmt;
695696
pub mod prelude;
696697
pub mod serial;
697698
pub mod spi;

0 commit comments

Comments
 (0)