Enum pretty::BuildDoc

source ·
pub enum BuildDoc<'a, D, A>
where D: DocPtr<'a, A>,
{ DocPtr(D), Doc(Doc<'a, D, A>), }
Expand description

Either a Doc or a pointer to a Doc (D)

Variants§

§

DocPtr(D)

§

Doc(Doc<'a, D, A>)

Implementations§

source§

impl<'a, D, A> BuildDoc<'a, D, A>
where D: DocPtr<'a, A>,

source

pub fn nil() -> Self

An empty document.

source

pub fn hardline() -> Self

A single hardline.

source

pub fn space() -> Self

source

pub fn fail() -> Self

source§

impl<'a, D, A> BuildDoc<'a, D, A>
where D: StaticDoc<'a, A>,

source

pub fn line() -> Self

A line acts like a \n but behaves like space if it is grouped on a single line.

source

pub fn line_() -> Self

Acts like line but behaves like nil if grouped on a single line

source§

impl<'a, T, A> BuildDoc<'a, T, A>
where T: StaticDoc<'a, A>,

source

pub fn as_string<U: Display>(data: U) -> Self

The text t.to_string().

The given text must not contain line breaks.

source

pub fn text<U: Into<Cow<'a, str>>>(data: U) -> Self

The given text, which must not contain line breaks.

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

source

pub fn render<W>(&self, width: usize, out: &mut W) -> Result<()>
where W: ?Sized + Write,

Writes a rendered document to a std::io::Write object.

source

pub fn render_fmt<W>(&self, width: usize, out: &mut W) -> Result
where W: ?Sized + Write,

Writes a rendered document to a std::fmt::Write object.

source

pub fn render_raw<W>(&self, width: usize, out: &mut W) -> Result<(), W::Error>
where for<'b> W: RenderAnnotated<'b, A> + ?Sized,

Writes a rendered document to a RenderAnnotated<A> object.

source

pub fn pretty<'d>(&'d self, width: usize) -> PrettyFmt<'a, 'd, T, A>

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

Trait Implementations§

source§

impl<'a, D, A: Clone> Clone for BuildDoc<'a, D, A>
where D: DocPtr<'a, A> + Clone,

source§

fn clone(&self) -> BuildDoc<'a, D, A>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, D, A> Debug for BuildDoc<'a, D, A>
where D: DocPtr<'a, A> + Debug, A: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, D, A> Default for BuildDoc<'a, D, A>
where D: DocPtr<'a, A>,

source§

fn default() -> Self

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

impl<'a, D, A> Deref for BuildDoc<'a, D, A>
where D: DocPtr<'a, A>,

§

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

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a, T, A> From<&'a String> for BuildDoc<'a, T, A>
where T: StaticDoc<'a, A>,

source§

fn from(s: &'a String) -> Self

Converts to this type from the input type.
source§

impl<'a, T, A> From<&'a str> for BuildDoc<'a, T, A>
where T: StaticDoc<'a, A>,

source§

fn from(s: &'a str) -> Self

Converts to this type from the input type.
source§

impl<'a, A> From<BoxDoc<'a, A>> for BuildDoc<'a, BoxDoc<'a, A>, A>

source§

fn from(s: BoxDoc<'a, A>) -> Self

Converts to this type from the input type.
source§

impl<'a, T, A> From<Doc<'a, T, A>> for BuildDoc<'a, T, A>
where T: DocPtr<'a, A>,

source§

fn from(s: Doc<'a, T, A>) -> Self

Converts to this type from the input type.
source§

impl<'a, D, A> From<DocBuilder<'a, D, A>> for BuildDoc<'a, D::Doc, A>
where D: ?Sized + DocAllocator<'a, A>,

source§

fn from(val: DocBuilder<'a, D, A>) -> Self

Converts to this type from the input type.
source§

impl<'a, T, A, S> From<Option<S>> for BuildDoc<'a, T, A>
where T: DocPtr<'a, A>, S: Into<BuildDoc<'a, T, A>>,

source§

fn from(s: Option<S>) -> Self

Converts to this type from the input type.
source§

impl<'a, A> From<RcDoc<'a, A>> for BuildDoc<'a, RcDoc<'a, A>, A>

source§

fn from(s: RcDoc<'a, A>) -> Self

Converts to this type from the input type.
source§

impl<'a, A> From<RefDoc<'a, A>> for BuildDoc<'a, RefDoc<'a, A>, A>

source§

fn from(s: RefDoc<'a, A>) -> Self

Converts to this type from the input type.
source§

impl<'a, T, A> From<String> for BuildDoc<'a, T, A>
where T: StaticDoc<'a, A>,

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl<'a, D, A> Pretty<'a, D, A> for BuildDoc<'a, D::Doc, A>
where A: 'a, D: ?Sized + DocAllocator<'a, A>,

source§

fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D, A>

Converts self into a document

Auto Trait Implementations§

§

impl<'a, D, A> Freeze for BuildDoc<'a, D, A>
where D: Freeze, A: Freeze, <D as DocPtr<'a, A>>::ColumnFn: Freeze,

§

impl<'a, D, A> RefUnwindSafe for BuildDoc<'a, D, A>

§

impl<'a, D, A> Send for BuildDoc<'a, D, A>
where D: Send, A: Send, <D as DocPtr<'a, A>>::ColumnFn: Send,

§

impl<'a, D, A> Sync for BuildDoc<'a, D, A>
where D: Sync, A: Sync, <D as DocPtr<'a, A>>::ColumnFn: Sync,

§

impl<'a, D, A> Unpin for BuildDoc<'a, D, A>
where D: Unpin, A: Unpin, <D as DocPtr<'a, A>>::ColumnFn: Unpin,

§

impl<'a, D, A> UnwindSafe for BuildDoc<'a, D, A>
where D: UnwindSafe, A: UnwindSafe, <D as DocPtr<'a, A>>::ColumnFn: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.