From 0eba0e2056b44462f92c327df92140956ffda265 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 14 Sep 2018 17:08:21 -0700 Subject: [PATCH] Attempt to make `AnsiOutput` play nicer with `write!` --- src/modules/output/ansi_output.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/modules/output/ansi_output.rs b/src/modules/output/ansi_output.rs index 7f1a3e1..33a7194 100644 --- a/src/modules/output/ansi_output.rs +++ b/src/modules/output/ansi_output.rs @@ -14,25 +14,23 @@ pub struct AnsiOutput { impl IStdout for AnsiOutput { fn write_str(&self, string: &str) -> io::Result { - let out = &self.handle; - let mut handle = out.lock(); - write!(handle, "{}", string)?; - handle.flush(); - Ok(0) + let out = &self.handle; + let mut handle = out.lock(); + let amt = handle.write(string.as_bytes())?; + handle.flush()?; + Ok(amt) } fn write(&self, buf: &[u8]) -> io::Result { let out = &self.handle; let mut handle = out.lock(); - handle.write(buf)?; - Ok(0) + handle.write(buf) } fn flush(&self) -> io::Result<()> { let out = &self.handle; let mut handle = out.lock(); - handle.flush(); - Ok(()) + handle.flush() } fn as_any(&self) -> &Any {