Enum pretty::Doc[][src]

pub enum Doc<'a, T, A = ()> {
    Nil,
    Append(T, T),
    Group(T),
    Nest(usize, T),
    Space,
    Newline,
    Text(Cow<'a, str>),
    Annotated(A, T),
}

The concrete document type. This type is not meant to be used directly. Instead use the static functions on Doc or the methods on an DocAllocator.

The T parameter is used to abstract over pointers to Doc. See RefDoc and BoxDoc for how it is used

Variants

Methods

impl<'a, T, A> Doc<'a, T, A>
[src]

An empty document.

The text t.to_string().

The given text must not contain line breaks.

A single newline.

The given text, which must not contain line breaks.

A space.

impl<'a, A> Doc<'a, BoxDoc<'a, A>, A>
[src]

Append the given document after this document.

A single document concatenating all the given documents.

A single document interspersing the given separator S between the given documents. For example, if the documents are [A, B, C, ..., Z], this yields [A, S, B, S, C, S, ..., S, Z].

Compare the intersperse method from the itertools crate.

Mark this document as a group.

Groups are layed out on a single line if possible. Within a group, all basic documents with several possible layouts are assigned the same layout, that is, they are all layed out horizontally and combined into a one single line, or they are each layed out on their own line.

Increase the indentation level of this document.

impl<'a, T, A> Doc<'a, T, A>
[src]

Writes a rendered document to a std::io::Write object.

Writes a rendered document to a std::fmt::Write object.

Writes a rendered document to a RenderAnnotated<A> object.

Returns a value which implements std::fmt::Display

use pretty::Doc;
let doc = Doc::<_>::group(
    Doc::text("hello").append(Doc::space()).append(Doc::text("world"))
);
assert_eq!(format!("{}", doc.pretty(80)), "hello world");

impl<'a, T> Doc<'a, T, ColorSpec>
[src]

Trait Implementations

impl<'a, T: Clone, A: Clone> Clone for Doc<'a, T, A>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a, T: Debug, A: Debug> Debug for Doc<'a, T, A>
[src]

Formats the value using the given formatter. Read more

impl<'a, T: Eq, A: Eq> Eq for Doc<'a, T, A>
[src]

impl<'a, T: Ord, A: Ord> Ord for Doc<'a, T, A>
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl<'a, T: PartialEq, A: PartialEq> PartialEq for Doc<'a, T, A>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'a, T: PartialOrd, A: PartialOrd> PartialOrd for Doc<'a, T, A>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<'a, T, A, S> From<S> for Doc<'a, T, A> where
    S: Into<Cow<'a, str>>, 
[src]

Performs the conversion.

impl<'a, D: ?Sized, A> Into<Doc<'a, D::Doc, A>> for DocBuilder<'a, D, A> where
    D: DocAllocator<'a, A>, 
[src]

Performs the conversion.

Auto Trait Implementations

impl<'a, T, A> Send for Doc<'a, T, A> where
    A: Send,
    T: Send

impl<'a, T, A> Sync for Doc<'a, T, A> where
    A: Sync,
    T: Sync