Last active
December 14, 2022 13:27
-
-
Save xkr47/191bead8f0ccc5954744e297cbf8942c to your computer and use it in GitHub Desktop.
UTF-8 -emitting fmt::Write wrapper for io::Write
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct FmtWriter<W: std::io::Write>(W); | |
impl <W: std::io::Write> std::fmt::Write for FmtWriter<W> { | |
fn write_str(&mut self, s: &str) -> fmt::Result { | |
self.0.write_all(s.as_bytes()).map_err(|_| fmt::Error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment