Skip to content

Commit

Permalink
Attempt to make AnsiOutput play nicer with write!
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw authored and TimonPost committed Sep 16, 2018
1 parent 4d60ac9 commit 0eba0e2
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/modules/output/ansi_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,23 @@ pub struct AnsiOutput {

impl IStdout for AnsiOutput {
fn write_str(&self, string: &str) -> io::Result<usize> {
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<usize> {
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 {
Expand Down

0 comments on commit 0eba0e2

Please sign in to comment.