Skip to main content

PrintWriter

Struct PrintWriter 

Source
pub struct PrintWriter { /* private fields */ }

Implementations§

Source§

impl PrintWriter

Source

pub fn new(writer: Box<dyn Write>) -> Self

Source

pub fn new_auto_flush(writer: Box<dyn Write>) -> Self

Source

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.

Source

pub fn print(&mut self, text: &str)

Source

pub fn println(&mut self, text: &str)

Source

pub fn printf(&mut self, args: Arguments<'_>)

Source

pub fn newline(&mut self)

Source

pub fn flush(&mut self)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.