Skip to content

Commit d60b964

Browse files
authored
Fix return value of Write::write impl for Pipe (#120)
* Fix return value of `Write::write` impl for `Pipe` This should return the number of bytes written, which as implemented is the whole buffer. Without this, the default `write_all` implementation won't work correctly, which is a problem with c520a21. * Use `.write` instead of `printfl!` to write `""` Now that `printfl!` calls `write_all`, rather than `write`, this no longer works. The `write_all` implementation provided by the `Write` trait writes until the buffer of bytes left to write is empty, so `write` is never if an empty string is passed, and thus a `Pipe` doesn't send a message with `done`. There are probably better ways to deal with the APIs involved here, but this at least fixes the behavior.
1 parent 87db6b8 commit d60b964

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/multi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl Write for Pipe {
251251
string: s,
252252
})
253253
.unwrap();
254-
Ok(1)
254+
Ok(buf.len())
255255
}
256256

257257
fn flush(&mut self) -> Result<()> {

src/pb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl<T: Write> ProgressBar<T> {
429429
/// the last time
430430
pub fn finish(&mut self) {
431431
self.finish_draw();
432-
printfl!(self.handle, "");
432+
self.handle.write(b"").expect("write() failed");
433433
}
434434

435435
/// Call finish and write string `s` that will replace the progress bar.

0 commit comments

Comments
 (0)