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§
Sourcefn nil(&self) -> DocBuilder<A>
fn nil(&self) -> DocBuilder<A>
Returns an empty document.
Mirrors pretty::DocAllocator::nil.
Sourcefn fail(&self) -> DocBuilder<A>
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.
Sourcefn hardline(&self) -> DocBuilder<A>
fn hardline(&self) -> DocBuilder<A>
Inserts a mandatory line break.
Mirrors pretty::DocAllocator::hardline.
Sourcefn space(&self) -> DocBuilder<A>
fn space(&self) -> DocBuilder<A>
Inserts a single space that disappears when groups flatten.
Mirrors pretty::DocAllocator::space.
Sourcefn line(&self) -> DocBuilder<A>
fn line(&self) -> DocBuilder<A>
Acts like a \n but behaves like space once grouped onto a single line.
Mirrors pretty::DocAllocator::line.
Sourcefn line_(&self) -> DocBuilder<A>
fn line_(&self) -> DocBuilder<A>
Acts like line but collapses to nil if grouped on a single line.
Mirrors pretty::DocAllocator::line_.
Sourcefn softline(&self) -> DocBuilder<A>
fn softline(&self) -> DocBuilder<A>
Acts like space when the document fits the page, otherwise behaves like line.
Mirrors pretty::DocAllocator::softline.
Sourcefn softline_(&self) -> DocBuilder<A>
fn softline_(&self) -> DocBuilder<A>
Acts like nil when the document fits the page, otherwise behaves like line_.
Mirrors pretty::DocAllocator::softline_.
Sourcefn as_string<U: Display>(&self, data: U) -> DocBuilder<A>
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.
Sourcefn text<'a>(&self, data: impl Into<Cow<'a, str>>) -> DocBuilder<A>
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.
Sourcefn concat<I>(&self, docs: I) -> DocBuilder<A>
fn concat<I>(&self, docs: I) -> DocBuilder<A>
Concatenates the given values after turning each into a document.
Mirrors pretty::DocAllocator::concat.
Sourcefn 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 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.
Sourcefn reflow(&self, text: &'static str) -> DocBuilder<A>where
A: Clone,
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".