pub struct PrintWriter { /* private fields */ }Implementations§
Source§impl PrintWriter
impl PrintWriter
pub fn new(writer: Box<dyn Write>) -> Self
pub fn new_auto_flush(writer: Box<dyn Write>) -> Self
Sourcepub fn exit_quietly_on_broken_pipe(self, value: bool) -> Self
pub fn exit_quietly_on_broken_pipe(self, value: bool) -> Self
Opts into treating a broken pipe as “exit the process quietly” instead of
panicking. Only appropriate for a writer that’s actually connected to something
pipe-like (e.g. a CLI’s stdout, which may be piped into head/less and closed
early - a routine condition every other Unix-style text-producing tool exits from
silently, and Rust ignoring SIGPIPE by default turns into an io::Error here
instead of the process dying outright). This is opt-in and off by default because
PrintWriter is also used to write to plain files (which can’t produce a broken
pipe in practice) and in-process buffers - an embedder writing to one of those
should never have the whole process exited out from under it by a shared
low-level writer type on some other, unexpected I/O condition.