[][src]Enum pretty::Doc

pub enum Doc<'a, T: DocPtr<'a, A>, A = ()> {
    Nil,
    Append(T, T),
    Group(T),
    FlatAlt(T, T),
    Nest(isize, T),
    Line,
    OwnedText(Box<str>),
    BorrowedText(&'a str),
    SmallText(SmallText),
    Annotated(A, T),
    Union(T, T),
    Column(T::ColumnFn),
    Nesting(T::ColumnFn),
}

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)
Group(T)
FlatAlt(T, T)
Nest(isize, T)
Line
OwnedText(Box<str>)
BorrowedText(&'a str)
SmallText(SmallText)
Annotated(A, T)
Union(T, T)
Column(T::ColumnFn)
Nesting(T::ColumnFn)

Methods

impl<'a, D, A> Doc<'a, D, A> where
    D: DocPtr<'a, A>, 
[src]

pub fn nil() -> Self[src]

An empty document.

pub fn as_string<U: Display>(data: U) -> Self[src]

The text t.to_string().

The given text must not contain line breaks.

pub fn hardline() -> Self[src]

A single hardline.

pub fn text<U: Into<Cow<'a, str>>>(data: U) -> Self[src]

The given text, which must not contain line breaks.

pub fn space() -> Self[src]

impl<'a, D, A> Doc<'a, D, A> where
    D: StaticDoc<'a, A>, 
[src]

pub fn line() -> Self[src]

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

pub fn line_() -> Self[src]

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

impl<'a, T, A> Doc<'a, T, A> where
    T: DocPtr<'a, A> + 'a, 
[src]

pub fn render<W: ?Sized>(&self, width: usize, out: &mut W) -> Result<()> where
    W: Write
[src]

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

pub fn render_fmt<W: ?Sized>(&self, width: usize, out: &mut W) -> Result where
    W: Write
[src]

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

pub fn render_raw<W: ?Sized>(
    &self,
    width: usize,
    out: &mut W
) -> Result<(), W::Error> where
    W: RenderAnnotated<A>, 
[src]

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

pub fn pretty<'d>(&'d self, width: usize) -> Pretty<'a, 'd, T, A>[src]

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");

impl<'a, T> Doc<'a, T, ColorSpec> where
    T: DocPtr<'a, ColorSpec> + 'a, 
[src]

pub fn render_colored<W>(&self, width: usize, out: W) -> Result<()> where
    W: WriteColor, 
[src]

Trait Implementations

impl<'a, T: Clone + DocPtr<'a, A>, A: Clone> Clone for Doc<'a, T, A> where
    T::ColumnFn: Clone,
    T::ColumnFn: Clone
[src]

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

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

impl<'a, A> From<Doc<'a, RcDoc<'a, A>, A>> for RcDoc<'a, A>[src]

impl<'a, T, A> From<Doc<'a, T, A>> for BuildDoc<'a, T, A> where
    T: DocPtr<'a, A>, 
[src]

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

Auto Trait Implementations

impl<'a, T, A> RefUnwindSafe for Doc<'a, T, A> where
    A: RefUnwindSafe,
    T: RefUnwindSafe,
    <T as DocPtr<'a, A>>::ColumnFn: RefUnwindSafe

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

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

impl<'a, T, A> Unpin for Doc<'a, T, A> where
    A: Unpin,
    T: Unpin,
    <T as DocPtr<'a, A>>::ColumnFn: Unpin

impl<'a, T, A> UnwindSafe for Doc<'a, T, A> where
    A: UnwindSafe,
    T: UnwindSafe,
    <T as DocPtr<'a, A>>::ColumnFn: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.