[−][src]Struct pretty::BoxDoc
Methods
impl<'a, A> BoxDoc<'a, A>
[src]
impl<'a, A> BoxDoc<'a, A>
[src]
pub fn nil() -> Self
[src]
An empty document.
pub fn as_string<U: Display>(data: U) -> Self
[src]
The text t.to_string()
.
The given text must not contain line breaks.
pub fn hardline() -> Self
[src]
A single hardline.
pub fn text<U: Into<Cow<'a, str>>>(data: U) -> Self
[src]
The given text, which must not contain line breaks.
pub fn space() -> Self
[src]
impl<'a, A> BoxDoc<'a, A>
[src]
pub fn line() -> Self
[src]
A line acts like a \n
but behaves like space
if it is grouped on a single line.
pub fn line_() -> Self
[src]
Acts like line
but behaves like nil
if grouped on a single line
impl<'a, A> BoxDoc<'a, A>
[src]
pub fn append<D>(self, that: D) -> Self where
D: Into<BuildDoc<'a, Self, A>>,
[src]
D: Into<BuildDoc<'a, Self, A>>,
Append the given document after this document.
pub fn concat<I>(docs: I) -> Self where
I: IntoIterator,
I::Item: Into<BuildDoc<'a, Self, A>>,
[src]
I: IntoIterator,
I::Item: Into<BuildDoc<'a, Self, A>>,
A single document concatenating all the given documents.
pub fn intersperse<I, S>(docs: I, separator: S) -> Self where
I: IntoIterator,
I::Item: Into<BuildDoc<'a, Self, A>>,
S: Into<BuildDoc<'a, Self, A>> + Clone,
A: Clone,
[src]
I: IntoIterator,
I::Item: Into<BuildDoc<'a, Self, A>>,
S: Into<BuildDoc<'a, Self, A>> + Clone,
A: Clone,
A single document interspersing the given separator S
between the given documents. For
example, if the documents are [A, B, C, ..., Z]
, this yields [A, S, B, S, C, S, ..., S, Z]
.
Compare the intersperse
method from the itertools
crate.
NOTE: The separator type, S
may need to be cloned. Consider using cheaply cloneable ptr
like RefDoc
or RcDoc
pub fn flat_alt<D>(self, doc: D) -> Self where
D: Into<BuildDoc<'a, Self, A>>,
[src]
D: Into<BuildDoc<'a, Self, A>>,
Acts as self
when laid out on multiple lines and acts as that
when laid out on a single line.
pub fn group(self) -> Self
[src]
Mark this document as a group.
Groups are layed out on a single line if possible. Within a group, all basic documents with several possible layouts are assigned the same layout, that is, they are all layed out horizontally and combined into a one single line, or they are each layed out on their own line.
pub fn nest(self, offset: isize) -> Self
[src]
Increase the indentation level of this document.
pub fn annotate(self, ann: A) -> Self
[src]
pub fn union<D>(self, other: D) -> Self where
D: Into<BuildDoc<'a, Self, A>>,
[src]
D: Into<BuildDoc<'a, Self, A>>,
Methods from Deref<Target = Doc<'a, BoxDoc<'a, A>, A>>
pub fn render<W: ?Sized>(&self, width: usize, out: &mut W) -> Result<()> where
W: Write,
[src]
W: Write,
Writes a rendered document to a std::io::Write
object.
pub fn render_fmt<W: ?Sized>(&self, width: usize, out: &mut W) -> Result where
W: Write,
[src]
W: Write,
Writes a rendered document to a std::fmt::Write
object.
pub fn render_raw<W: ?Sized>(
&self,
width: usize,
out: &mut W
) -> Result<(), W::Error> where
W: RenderAnnotated<A>,
[src]
&self,
width: usize,
out: &mut W
) -> Result<(), W::Error> where
W: RenderAnnotated<A>,
Writes a rendered document to a RenderAnnotated<A>
object.
pub fn pretty<'d>(&'d self, width: usize) -> Pretty<'a, 'd, T, A>
[src]
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");
pub fn render_colored<W>(&self, width: usize, out: W) -> Result<()> where
W: WriteColor,
[src]
W: WriteColor,
Trait Implementations
impl<'a, A: Clone> Clone for BoxDoc<'a, A>
[src]
impl<'a, A> Debug for BoxDoc<'a, A> where
A: Debug,
[src]
A: Debug,
impl<'a, A> Deref for BoxDoc<'a, A>
[src]
type Target = Doc<'a, BoxDoc<'a, A>, A>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<'a, A> DocPtr<'a, A> for BoxDoc<'a, A>
[src]
impl<'a, A> From<BoxDoc<'a, A>> for BuildDoc<'a, BoxDoc<'a, A>, A>
[src]
impl<'a, A> From<Doc<'a, BoxDoc<'a, A>, A>> for BoxDoc<'a, A>
[src]
impl<'a, A> StaticDoc<'a, A> for BoxDoc<'a, A>
[src]
type Allocator = BoxAllocator
const ALLOCATOR: &'static Self::Allocator
[src]
Auto Trait Implementations
impl<'a, A = ()> !RefUnwindSafe for BoxDoc<'a, A>
impl<'a, A = ()> !Send for BoxDoc<'a, A>
impl<'a, A = ()> !Sync for BoxDoc<'a, A>
impl<'a, A> Unpin for BoxDoc<'a, A>
impl<'a, A = ()> !UnwindSafe for BoxDoc<'a, A>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,