pub struct Arena<'a> { /* private fields */ }
Expand description
An arena which can be used to allocate Doc
values.
Implementations§
Trait Implementations§
Source§impl<'a> DocAllocator<'a> for Arena<'a>
impl<'a> DocAllocator<'a> for Arena<'a>
Source§fn text<U>(&'a self, data: U) -> DocBuilder<'a, Arena<'a>>
fn text<U>(&'a self, data: U) -> DocBuilder<'a, Arena<'a>>
Optimized text allocation for common ASCII characters.
type Doc = RefDoc<'a>
fn alloc( &'a self, doc: Doc<'a, <Arena<'a> as DocAllocator<'a>>::Doc>, ) -> <Arena<'a> as DocAllocator<'a>>::Doc
fn space(&'a self) -> DocBuilder<'a, Arena<'a>>
fn alloc_cow(&'a self, doc: BuildDoc<'a, Self::Doc>) -> Self::Doc
Source§fn nil(&'a self) -> DocBuilder<'a, Self>
fn nil(&'a self) -> DocBuilder<'a, Self>
Allocate an empty document.
Source§fn fail(&'a self) -> DocBuilder<'a, Self>
fn fail(&'a self) -> DocBuilder<'a, Self>
Fails document rendering immediately. Read more
Source§fn hardline(&'a self) -> DocBuilder<'a, Self>
fn hardline(&'a self) -> DocBuilder<'a, Self>
Allocate a single hardline.
Source§fn line(&'a self) -> DocBuilder<'a, Self>
fn line(&'a self) -> DocBuilder<'a, Self>
A line acts like a
\n
but behaves like space
if it is grouped on a single line.Source§fn line_(&'a self) -> DocBuilder<'a, Self>
fn line_(&'a self) -> DocBuilder<'a, Self>
Source§fn softline(&'a self) -> DocBuilder<'a, Self>
fn softline(&'a self) -> DocBuilder<'a, Self>
A
softline
acts like space
if the document fits the page, otherwise like line
Source§fn softline_(&'a self) -> DocBuilder<'a, Self>
fn softline_(&'a self) -> DocBuilder<'a, Self>
A
softline_
acts like nil
if the document fits the page, otherwise like line_
Source§fn if_group_flat(&'a self, doc: impl Pretty<'a, Self>) -> DocBuilder<'a, Self>
fn if_group_flat(&'a self, doc: impl Pretty<'a, Self>) -> DocBuilder<'a, Self>
Equivalent to
self.nil().flat_alt(doc.pretty(self))
Source§fn if_group_break(&'a self, doc: impl Pretty<'a, Self>) -> DocBuilder<'a, Self>
fn if_group_break(&'a self, doc: impl Pretty<'a, Self>) -> DocBuilder<'a, Self>
Equivalent to
doc.pretty(self).flat_alt(self.nil())
Source§fn expand_parent(&'a self) -> DocBuilder<'a, Self>
fn expand_parent(&'a self) -> DocBuilder<'a, Self>
Make the parent group break Read more
Source§fn as_string<U>(&'a self, data: U) -> DocBuilder<'a, Self>where
U: Display,
fn as_string<U>(&'a self, data: U) -> DocBuilder<'a, Self>where
U: Display,
Allocate a document containing the text
t.to_string()
. Read moreSource§fn ascii_text<U>(&'a self, data: U) -> DocBuilder<'a, Self>
fn ascii_text<U>(&'a self, data: U) -> DocBuilder<'a, Self>
Allocate a document containing the given text, which is assumed to be ASCII. Read more
Source§fn spaces(&'a self, n: usize) -> DocBuilder<'a, Self>
fn spaces(&'a self, n: usize) -> DocBuilder<'a, Self>
Allocate a document containing n spaces.
Source§fn line_suffix(&'a self, doc: impl Pretty<'a, Self>) -> DocBuilder<'a, Self>
fn line_suffix(&'a self, doc: impl Pretty<'a, Self>) -> DocBuilder<'a, Self>
Pushes some content to the end of the current line. Read more
Source§fn concat<I>(&'a self, docs: I) -> DocBuilder<'a, Self>
fn concat<I>(&'a self, docs: I) -> DocBuilder<'a, Self>
Allocate a document concatenating the given documents.
Source§fn intersperse<I, S>(&'a self, docs: I, separator: S) -> DocBuilder<'a, Self>
fn intersperse<I, S>(&'a self, docs: I, separator: S) -> DocBuilder<'a, Self>
Allocate a document that intersperses the given separator
S
between the given documents
[A, B, C, ..., Z]
, yielding [A, S, B, S, C, S, ..., S, Z]
. Read moreAuto Trait Implementations§
impl<'a> !Freeze for Arena<'a>
impl<'a> !RefUnwindSafe for Arena<'a>
impl<'a> Send for Arena<'a>
impl<'a> !Sync for Arena<'a>
impl<'a> Unpin for Arena<'a>
impl<'a> UnwindSafe for Arena<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more