Struct pretty::RefDoc

source ·
pub struct RefDoc<'a, A = ()>(pub &'a Doc<'a, RefDoc<'a, A>, A>);
Expand description

Newtype wrapper for &Doc

Tuple Fields§

§0: &'a Doc<'a, RefDoc<'a, A>, A>

Methods from Deref<Target = Doc<'a, RefDoc<'a, A>, 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) -> Resultwhere 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");
source

pub fn render_colored<W>(&self, width: usize, out: W) -> Result<()>where W: WriteColor,

Trait Implementations§

source§

impl<A> Clone for RefDoc<'_, A>

source§

fn clone(&self) -> Self

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, A> Debug for RefDoc<'a, A>where A: Debug,

source§

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

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

impl<'a, A> Deref for RefDoc<'a, A>

§

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

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<'a, A> DocPtr<'a, A> for RefDoc<'a, A>

§

type ColumnFn = &'a dyn Fn(usize) -> RefDoc<'a, A>

§

type WidthFn = &'a dyn Fn(isize) -> RefDoc<'a, A>

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, A> Pretty<'a, Arena<'a, A>, A> for RefDoc<'a, A>where A: 'a,

source§

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

Converts self into a document
source§

impl<A> Copy for RefDoc<'_, A>

Auto Trait Implementations§

§

impl<'a, A = ()> !RefUnwindSafe for RefDoc<'a, A>

§

impl<'a, A = ()> !Send for RefDoc<'a, A>

§

impl<'a, A = ()> !Sync for RefDoc<'a, A>

§

impl<'a, A> Unpin for RefDoc<'a, A>

§

impl<'a, A = ()> !UnwindSafe for RefDoc<'a, A>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.