Sanity check that we actually flush all buffers

This commit is contained in:
Oli Scherer 2023-07-26 18:52:08 +00:00
parent d9deaf4b8a
commit 375d8f1b25

View File

@ -2617,6 +2617,15 @@ impl Write for Buffy {
} }
} }
impl Drop for Buffy {
fn drop(&mut self) {
if !self.buffer.is_empty() {
self.flush().unwrap();
panic!("buffers need to be flushed in order to print their contents");
}
}
}
impl WriteColor for Buffy { impl WriteColor for Buffy {
fn supports_color(&self) -> bool { fn supports_color(&self) -> bool {
self.buffer.supports_color() self.buffer.supports_color()