another_html_builder/
prelude.rs1pub trait WriterExt {
5 type Error: std::error::Error;
6
7 fn write<E: std::fmt::Display>(&mut self, input: E) -> Result<(), Self::Error>;
9 fn write_str(&mut self, input: &str) -> Result<(), Self::Error>;
10 fn write_char(&mut self, input: char) -> Result<(), Self::Error>;
11}
12
13pub struct FmtWriter<W>(pub W);
15
16impl<W: std::fmt::Write> WriterExt for FmtWriter<W> {
17 type Error = std::fmt::Error;
18 fn write<E: std::fmt::Display>(&mut self, input: E) -> Result<(), Self::Error> {
19 write!(&mut self.0, "{input}")
20 }
21
22 fn write_str(&mut self, input: &str) -> Result<(), Self::Error> {
23 self.0.write_str(input)
24 }
25
26 fn write_char(&mut self, input: char) -> Result<(), Self::Error> {
27 self.0.write_char(input)
28 }
29}
30
31pub struct IoWriter<W>(pub W);
33
34impl<W: std::io::Write> WriterExt for IoWriter<W> {
35 type Error = std::io::Error;
36
37 fn write<E: std::fmt::Display>(&mut self, input: E) -> std::io::Result<()> {
38 write!(self.0, "{input}")
39 }
40
41 fn write_str(&mut self, input: &str) -> std::io::Result<()> {
42 write!(self.0, "{input}")
43 }
44
45 fn write_char(&mut self, input: char) -> std::io::Result<()> {
46 write!(self.0, "{input}")
47 }
48}