Struct Arena

Source
pub struct Arena<'a> { /* private fields */ }
Expand description

An arena which can be used to allocate Doc values.

Implementations§

Source§

impl<'a> Arena<'a>

Source

pub fn new() -> Arena<'a>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Default for Arena<'_>

Source§

fn default() -> Arena<'_>

Returns the “default value” for a type. Read more
Source§

impl<'a> DocAllocator<'a> for Arena<'a>

Source§

fn text<U>(&'a self, data: U) -> DocBuilder<'a, Arena<'a>>
where U: Into<Cow<'a, str>>,

Optimized text allocation for common ASCII characters.

Source§

type Doc = RefDoc<'a>

Source§

fn alloc( &'a self, doc: Doc<'a, <Arena<'a> as DocAllocator<'a>>::Doc>, ) -> <Arena<'a> as DocAllocator<'a>>::Doc

Source§

fn space(&'a self) -> DocBuilder<'a, Arena<'a>>

Source§

fn alloc_cow(&'a self, doc: BuildDoc<'a, Self::Doc>) -> Self::Doc

Source§

fn nil(&'a self) -> DocBuilder<'a, Self>

Allocate an empty document.
Source§

fn fail(&'a self) -> DocBuilder<'a, Self>

Fails document rendering immediately. Read more
Source§

fn hardline(&'a self) -> DocBuilder<'a, Self>

Allocate a single hardline.
Source§

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>

Acts like line but behaves like nil if grouped on a single line Read more
Source§

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>

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>

Equivalent to self.nil().flat_alt(doc.pretty(self))
Source§

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>

Make the parent group break Read more
Source§

fn as_string<U>(&'a self, data: U) -> DocBuilder<'a, Self>
where U: Display,

Allocate a document containing the text t.to_string(). Read more
Source§

fn ascii_text<U>(&'a self, data: U) -> DocBuilder<'a, Self>
where U: Into<Cow<'a, str>>,

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>

Allocate a document containing n spaces.
Source§

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>
where I: IntoIterator, <I as IntoIterator>::Item: Pretty<'a, Self>,

Allocate a document concatenating the given documents.
Source§

fn intersperse<I, S>(&'a self, docs: I, separator: S) -> DocBuilder<'a, Self>
where I: IntoIterator, <I as IntoIterator>::Item: Pretty<'a, Self>, S: Pretty<'a, Self> + Clone,

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 more
Source§

fn reflow(&'a self, text: &'a str) -> DocBuilder<'a, Self>
where Self: Sized, Self::Doc: Clone,

Reflows text inserting softline in place of any whitespace

Auto 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.