Document

Enum Document 

Source
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

Source

pub fn is_empty(&self) -> bool

Returns true if this document has no content, i.e. Document::Empty

Source

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 Add<&'static str> for Document

Source§

fn add(self, other: &'static str) -> <Document as Add<&'static str>>::Output

Concatenate the two documents

Source§

type Output = Document

The resulting type after applying the + operator.
Source§

impl Add<Document> for &'static str

Source§

fn add(self, other: Document) -> <&'static str as Add<Document>>::Output

Concatenate the two documents

Source§

type Output = Document

The resulting type after applying the + operator.
Source§

impl Add<char> for Document

Source§

fn add(self, other: char) -> <Document as Add<char>>::Output

Concatenate the two documents

Source§

type Output = Document

The resulting type after applying the + operator.
Source§

impl Add for Document

Source§

fn add(self, other: Document) -> <Document as Add>::Output

Concatenate the two documents

Source§

type Output = Document

The resulting type after applying the + operator.
Source§

impl AddAssign<&'static str> for Document

Source§

fn add_assign(&mut self, rhs: &'static str)

Append rhs to self

Source§

impl AddAssign<char> for Document

Source§

fn add_assign(&mut self, rhs: char)

Append rhs to self

Source§

impl AddAssign for Document

Source§

fn add_assign(&mut self, rhs: Document)

Append rhs to self

Source§

impl BitOr for Document

Source§

fn bitor(self, other: Document) -> <Document as BitOr>::Output

If inside a flat, or the first line of the left document fits within the required width, then display the left document. Otherwise, display the right document.

Source§

type Output = Document

The resulting type after applying the | operator.
Source§

impl Clone for Document

Source§

fn clone(&self) -> Document

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Document

Source§

fn default() -> Document

Returns the “default value” for a type. Read more
Source§

impl Display for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<&'static str> for Document

Source§

fn from(s: &'static str) -> Document

Converts to this type from the input type.
Source§

impl From<String> for Document

Source§

fn from(s: String) -> Document

Converts to this type from the input type.
Source§

impl From<char> for Document

Source§

fn from(c: char) -> Document

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V