Enum pretty::Doc[][src]

pub enum Doc<'a, T, A = ()> where
    T: DocPtr<'a, A>, 
{
Show 15 variants Nil, Append(T, T), Group(T), FlatAlt(T, T), Nest(isize, T), Hardline, RenderLen(usize, T), OwnedText(Box<str>), BorrowedText(&'a str), SmallText(SmallText), Annotated(A, T), Union(T, T), Column(T::ColumnFn), Nesting(T::ColumnFn), Fail,
}
Expand description

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

Nil

Append(T, T)

Tuple Fields

0: T
1: T

Group(T)

Tuple Fields

0: T

FlatAlt(T, T)

Tuple Fields

0: T
1: T

Nest(isize, T)

Tuple Fields

0: isize
1: T

Hardline

RenderLen(usize, T)

Tuple Fields

0: usize
1: T

OwnedText(Box<str>)

Tuple Fields

0: Box<str>

BorrowedText(&'a str)

Tuple Fields

0: &'a str

SmallText(SmallText)

Tuple Fields

Annotated(A, T)

Tuple Fields

0: A
1: T

Union(T, T)

Tuple Fields

0: T
1: T

Column(T::ColumnFn)

Tuple Fields

0: T::ColumnFn

Nesting(T::ColumnFn)

Tuple Fields

0: T::ColumnFn

Fail

Implementations

An empty document.

A single hardline.

A line acts like a \n but behaves like space if it is grouped on a single line.

Acts like line but behaves like nil if grouped on a single line

The text t.to_string().

The given text must not contain line breaks.

The given text, which must not contain line breaks.

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, BoxDoc};
let doc = BoxDoc::<()>::group(
    BoxDoc::text("hello").append(Doc::line()).append(Doc::text("world"))
);
assert_eq!(format!("{}", doc.pretty(80)), "hello world");

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Converts self into a document

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.