Private helper struct for implementing the line-buffered writing logic.
This shim temporarily wraps a BufWriter, and uses its internals to
implement a line-buffered writer (specifically by using the internal
methods like write_to_buf and flush_buf). In this way, a more
efficient abstraction can be created than one that only had access to
write
and flush
, without needlessly duplicating a lot of the
implementation details of BufWriter. This also allows existing
BufWriters
to be temporarily given line-buffering logic; this is what
enables Stdout to be alternately in line-buffered or block-buffered mode.