ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: relax error type of LogContentFormat::write()

This commit is contained in:
Yuya Nishihara 2024-09-03 18:28:00 +09:00
parent 6154827129
commit babdf6b9c1

View file

@ -2359,18 +2359,19 @@ impl LogContentFormat {
} }
/// Writes content which will optionally be wrapped at the current width. /// Writes content which will optionally be wrapped at the current width.
pub fn write( pub fn write<E: From<io::Error>>(
&self, &self,
formatter: &mut dyn Formatter, formatter: &mut dyn Formatter,
content_fn: impl FnOnce(&mut dyn Formatter) -> std::io::Result<()>, content_fn: impl FnOnce(&mut dyn Formatter) -> Result<(), E>,
) -> std::io::Result<()> { ) -> Result<(), E> {
if self.word_wrap { if self.word_wrap {
let mut recorder = FormatRecorder::new(); let mut recorder = FormatRecorder::new();
content_fn(&mut recorder)?; content_fn(&mut recorder)?;
text_util::write_wrapped(formatter, &recorder, self.width) text_util::write_wrapped(formatter, &recorder, self.width)?;
} else { } else {
content_fn(formatter) content_fn(formatter)?;
} }
Ok(())
} }
} }