pub trait Print {
// Required method
fn print(&self, out: &mut dyn Write) -> Result<(), Error>;
// Provided method
fn to_source(&self) -> Result<String, Report> { ... }
}Expand description
Write a value in the source spelling accepted by its Parse
implementation.
Implementations must round-trip: parsing the printed text yields a value
equal to self. When no such spelling exists, return fmt::Error rather
than writing text that would parse differently.
fmt::Formatter implements fmt::Write, so a Display impl can
forward to print.
Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
§impl Print for Type
Print the canonical spelling of each type (the short form where the parser
accepts aliases, e.g. str and fn).
impl Print for Type
Print the canonical spelling of each type (the short form where the parser
accepts aliases, e.g. str and fn).
§impl Print for Value
Print a type-tagged value such as u64 3 or f64 -0.5.
impl Print for Value
Print a type-tagged value such as u64 3 or f64 -0.5.
Finite floats print as their shortest round-tripping decimal. NaN and the
infinities print as f64_bits/f32_bits so the exact bit pattern
(including NaN payloads) survives a reparse.