Skip to main content

PrettyAstExt

Trait PrettyAstExt 

Source
pub trait PrettyAstExt<A: 'static>: Sized {
Show 13 methods // Provided methods fn nil(&self) -> DocBuilder<A> { ... } fn fail(&self) -> DocBuilder<A> { ... } fn hardline(&self) -> DocBuilder<A> { ... } fn space(&self) -> DocBuilder<A> { ... } fn line(&self) -> DocBuilder<A> { ... } fn line_(&self) -> DocBuilder<A> { ... } fn softline(&self) -> DocBuilder<A> { ... } fn softline_(&self) -> DocBuilder<A> { ... } fn as_string<U: Display>(&self, data: U) -> DocBuilder<A> { ... } fn text<'a>(&self, data: impl Into<Cow<'a, str>>) -> DocBuilder<A> { ... } fn concat<I>(&self, docs: I) -> DocBuilder<A> where I::Item: ToDocumentOwned<Self, A>, I: IntoIterator { ... } fn intersperse<I, S>(&self, docs: I, separator: S) -> DocBuilder<A> where I::Item: ToDocumentOwned<Self, A>, I: IntoIterator, S: ToDocumentOwned<Self, A> + Clone, A: Clone { ... } fn reflow(&self, text: &'static str) -> DocBuilder<A> where A: Clone { ... }
}
Expand description

PrettyAstExt exposes DocAllocator-style constructors for printers.

Every method simply forwards to the global pretty::BoxAllocator so that printers implementing PrettyAst can build documents without juggling allocator plumbing.

Provided Methods§

Source

fn nil(&self) -> DocBuilder<A>

Returns an empty document. Mirrors pretty::DocAllocator::nil.

Source

fn fail(&self) -> DocBuilder<A>

Produces a document that fails rendering immediately. Mirrors pretty::DocAllocator::fail.

This is typically used to abort rendering inside the left side of a pretty::Doc::Union.

Source

fn hardline(&self) -> DocBuilder<A>

Inserts a mandatory line break. Mirrors pretty::DocAllocator::hardline.

Source

fn space(&self) -> DocBuilder<A>

Inserts a single space that disappears when groups flatten. Mirrors pretty::DocAllocator::space.

Source

fn line(&self) -> DocBuilder<A>

Acts like a \n but behaves like space once grouped onto a single line. Mirrors pretty::DocAllocator::line.

Source

fn line_(&self) -> DocBuilder<A>

Acts like line but collapses to nil if grouped on a single line. Mirrors pretty::DocAllocator::line_.

Source

fn softline(&self) -> DocBuilder<A>

Acts like space when the document fits the page, otherwise behaves like line. Mirrors pretty::DocAllocator::softline.

Source

fn softline_(&self) -> DocBuilder<A>

Acts like nil when the document fits the page, otherwise behaves like line_. Mirrors pretty::DocAllocator::softline_.

Source

fn as_string<U: Display>(&self, data: U) -> DocBuilder<A>

Renders data via its Display implementation. Mirrors pretty::DocAllocator::as_string.

The resulting document must not contain explicit line breaks.

Source

fn text<'a>(&self, data: impl Into<Cow<'a, str>>) -> DocBuilder<A>

Renders the provided text verbatim. Mirrors pretty::DocAllocator::text.

The supplied string must not contain line breaks.

Source

fn concat<I>(&self, docs: I) -> DocBuilder<A>
where I::Item: ToDocumentOwned<Self, A>, I: IntoIterator,

Concatenates the given values after turning each into a document. Mirrors pretty::DocAllocator::concat.

Source

fn intersperse<I, S>(&self, docs: I, separator: S) -> DocBuilder<A>
where I::Item: ToDocumentOwned<Self, A>, I: IntoIterator, S: ToDocumentOwned<Self, A> + Clone, A: Clone,

Concatenates documents while interspersing separator between every pair. Mirrors pretty::DocAllocator::intersperse.

separator may need to be cloned; consider cheap pointer documents like RefDoc or RcDoc.

Source

fn reflow(&self, text: &'static str) -> DocBuilder<A>
where A: Clone,

Reflows text, inserting softline wherever whitespace appears. Mirrors pretty::DocAllocator::reflow.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<A: 'static + Clone, P: PrettyAst<A>> PrettyAstExt<A> for P