pub enum Document {
Empty,
Newline,
Char(char, u32),
Text(Cow<'static, str>, u32),
Flatten(Rc<Document>),
Indent(u32, Rc<Document>),
Concat(Rc<Document>, Rc<Document>),
Choice(Rc<Document>, Rc<Document>),
}
Variants§
Empty
An empty document, rendered as an empty string
Newline
A line break, rendered as a single ‘\n’ char
Char(char, u32)
A single unicode character.
NOTE: Certain char
values are normalized to other Document variants, e.g. \n
becomes
a Document::Newline, not a Document::Char.
Text(Cow<'static, str>, u32)
A literal text string of width n
Flatten(Rc<Document>)
A combinator which chooses the leftmost of each choice in the given document
Indent(u32, Rc<Document>)
Increase the indentation of the given document by n
Concat(Rc<Document>, Rc<Document>)
Concatenate two documents
Choice(Rc<Document>, Rc<Document>)
Choose the more optimal of two documents depending on the amount of space remaining in the layout
Implementations§
Source§impl Document
impl Document
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this document has no content, i.e. Document::Empty
Sourcepub fn has_leading_newline(&self) -> bool
pub fn has_leading_newline(&self) -> bool
Returns true if the content of this document starts with a line break.
This is primarily intended for use by the pretty printer itself, but may be useful to others.
Trait Implementations§
Source§impl AddAssign<&'static str> for Document
impl AddAssign<&'static str> for Document
Source§fn add_assign(&mut self, rhs: &'static str)
fn add_assign(&mut self, rhs: &'static str)
Append rhs
to self
Source§impl AddAssign<char> for Document
impl AddAssign<char> for Document
Source§fn add_assign(&mut self, rhs: char)
fn add_assign(&mut self, rhs: char)
Append rhs
to self