Skip to content

Commit

Permalink
fix(fmt): Ensure stream gets flushed
Browse files Browse the repository at this point in the history
Fixes #278
  • Loading branch information
epage committed Jan 17, 2024
1 parent 2b3f26f commit c088820
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/fmt/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,20 @@ impl WritableTarget {
WritableTarget::WriteStdout => {
let mut stream = std::io::stdout().lock();
stream.write_all(buf)?;
stream.flush()?;
}
WritableTarget::PrintStdout => print!("{}", String::from_utf8_lossy(buf)),
WritableTarget::WriteStderr => {
let mut stream = std::io::stderr().lock();
stream.write_all(buf)?;
stream.flush()?;
}
WritableTarget::PrintStderr => eprint!("{}", String::from_utf8_lossy(buf)),
// Safety: If the target type is `Pipe`, `target_pipe` will always be non-empty.
WritableTarget::Pipe(pipe) => {
let mut stream = pipe.lock().unwrap();
stream.write_all(buf)?;
stream.flush()?;
}
}

Expand Down

0 comments on commit c088820

Please sign in to comment.