Skip to main content

Module print

Module print 

Source
Expand description

Canonical source printing: the inverse of Parse.

Every type with a Parse implementation in this crate also implements Print, and #[derive(Parse)] derives both from the same pattern, so parse(print(x)) == x holds for every printable value.

Output is canonical and minimal: one space between tokens, , between list items, no newlines, and no leading or trailing whitespace. Layout (indentation, line breaks) is left to callers, so printed fragments compose.

Printing fails with fmt::Error when a value has no source spelling that parses back to the same value, for example a non-finite f64, an empty or malformed Ident, or Some(x) whose spelling of x would be read as null.

Traits§

Print
Write a value in the source spelling accepted by its Parse implementation.

Functions§

print_quoted
Write text as a double-quoted string literal using the escapes accepted by the QuotedString parser.