Enum pretty::Doc [] [src]

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

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 B parameter is used to abstract over pointers to Doc. See RefDoc and BoxDoc for how it is used

Variants

Methods

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

[src]

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

[src]

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

[src]

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, B> Doc<'a, ColorSpec, B>
[src]

[src]

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

[src]

An empty document.

[src]

The text t.to_string().

The given text must not contain line breaks.

[src]

A single newline.

[src]

The given text, which must not contain line breaks.

[src]

A space.

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

[src]

Append the given document after this document.

[src]

A single document concatenating all the given documents.

[src]

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.

[src]

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.

[src]

Increase the indentation level of this document.

[src]

Trait Implementations

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

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

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

[src]

Formats the value using the given formatter. Read more

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

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

[src]

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

1.21.0
[src]

Compares and returns the maximum of two values. Read more

1.21.0
[src]

Compares and returns the minimum of two values. Read more

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

[src]

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

[src]

This method tests for !=.

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

Auto Trait Implementations

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

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