[][src]Struct pretty::BoxDoc

pub struct BoxDoc<'a, A = ()>(_);

Methods

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

pub fn new(doc: Doc<'a, BoxDoc<'a, A>, A>) -> BoxDoc<'a, A>[src]

impl<'a, A> BoxDoc<'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, A> BoxDoc<'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, A> BoxDoc<'a, A>[src]

pub fn append<D>(self, that: D) -> Self where
    D: Into<BuildDoc<'a, Self, A>>, 
[src]

Append the given document after this document.

pub fn concat<I>(docs: I) -> Self where
    I: IntoIterator,
    I::Item: Into<BuildDoc<'a, Self, A>>, 
[src]

A single document concatenating all the given documents.

pub fn intersperse<I, S>(docs: I, separator: S) -> Self where
    I: IntoIterator,
    I::Item: Into<BuildDoc<'a, Self, A>>,
    S: Into<BuildDoc<'a, Self, A>> + Clone,
    A: Clone
[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.

NOTE: The separator type, S may need to be cloned. Consider using cheaply cloneable ptr like RefDoc or RcDoc

pub fn flat_alt<D>(self, doc: D) -> Self where
    D: Into<BuildDoc<'a, Self, A>>, 
[src]

Acts as self when laid out on multiple lines and acts as that when laid out on a single line.

pub fn group(self) -> Self[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.

pub fn nest(self, offset: isize) -> Self[src]

Increase the indentation level of this document.

pub fn annotate(self, ann: A) -> Self[src]

pub fn union<D>(self, other: D) -> Self where
    D: Into<BuildDoc<'a, Self, A>>, 
[src]

Methods from Deref<Target = Doc<'a, BoxDoc<'a, A>, A>>

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

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

Trait Implementations

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

impl<'a, A> Debug for BoxDoc<'a, A> where
    A: Debug
[src]

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

type Target = Doc<'a, BoxDoc<'a, A>, A>

The resulting type after dereferencing.

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

type ColumnFn = Rc<dyn Fn(usize) -> Self + 'a>

type WidthFn = Rc<dyn Fn(isize) -> Self + 'a>

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

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

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

type Allocator = BoxAllocator

Auto Trait Implementations

impl<'a, A = ()> !RefUnwindSafe for BoxDoc<'a, A>

impl<'a, A = ()> !Send for BoxDoc<'a, A>

impl<'a, A = ()> !Sync for BoxDoc<'a, A>

impl<'a, A> Unpin for BoxDoc<'a, A>

impl<'a, A = ()> !UnwindSafe for BoxDoc<'a, A>

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.