|
if buf.len() >= self.buf.capacity() { |
Suppose you had a BufWriter with capacity 4. If you write b"1234" to it, that will be flushed directly to the underlying stream, but if you write b"12" and then b"34", those will be buffered. The unit tests confirm this behavior, but it seems surprising to me.
rust/src/libstd/io/buffered.rs
Line 662 in eeaf497
Suppose you had a
BufWriterwith capacity 4. If you writeb"1234"to it, that will be flushed directly to the underlying stream, but if you writeb"12"and thenb"34", those will be buffered. The unit tests confirm this behavior, but it seems surprising to me.