[−][src]Enum pretty::Doc
The concrete document type. This type is not meant to be used directly. Instead use the static
functions on Doc
or the methods on an DocAllocator
.
The T
parameter is used to abstract over pointers to Doc
. See RefDoc
and BoxDoc
for how
it is used
Variants
Nest(usize, T)
Methods
impl<'a, T, A> Doc<'a, T, A>
[src]
pub fn nil() -> Doc<'a, T, A>
[src]
An empty document.
pub fn as_string<U: ToString>(data: U) -> Doc<'a, T, A>
[src]
The text t.to_string()
.
The given text must not contain line breaks.
pub fn newline() -> Doc<'a, T, A>
[src]
A single newline.
pub fn text<U: Into<Cow<'a, str>>>(data: U) -> Doc<'a, T, A>
[src]
The given text, which must not contain line breaks.
pub fn space() -> Doc<'a, T, A>
[src]
A space.
impl<'a, A> Doc<'a, BoxDoc<'a, A>, A>
[src]
pub fn append<D>(self, that: D) -> Doc<'a, BoxDoc<'a, A>, A> where
D: Into<Doc<'a, BoxDoc<'a, A>, A>>,
[src]
D: Into<Doc<'a, BoxDoc<'a, A>, A>>,
Append the given document after this document.
pub fn concat<I>(docs: I) -> Doc<'a, BoxDoc<'a, A>, A> where
I: IntoIterator,
I::Item: Into<Doc<'a, BoxDoc<'a, A>, A>>,
[src]
I: IntoIterator,
I::Item: Into<Doc<'a, BoxDoc<'a, A>, A>>,
A single document concatenating all the given documents.
pub fn intersperse<I, S>(docs: I, separator: S) -> Doc<'a, BoxDoc<'a, A>, A> where
I: IntoIterator,
I::Item: Into<Doc<'a, BoxDoc<'a, A>, A>>,
S: Into<Doc<'a, BoxDoc<'a, A>, A>> + Clone,
A: Clone,
[src]
I: IntoIterator,
I::Item: Into<Doc<'a, BoxDoc<'a, A>, A>>,
S: Into<Doc<'a, BoxDoc<'a, A>, 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]
.
pub fn flat_alt<D>(self, doc: D) -> Doc<'a, BoxDoc<'a, A>, A> where
D: Into<Doc<'a, BoxDoc<'a, A>, A>>,
[src]
D: Into<Doc<'a, BoxDoc<'a, A>, 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) -> Doc<'a, BoxDoc<'a, A>, A>
[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: usize) -> Doc<'a, BoxDoc<'a, A>, A>
[src]
Increase the indentation level of this document.
pub fn space_() -> Doc<'a, BoxDoc<'a, A>, A>
[src]
Acts like space
but behaves like nil
if grouped on a single line
pub fn annotate(self, ann: A) -> Doc<'a, BoxDoc<'a, A>, A>
[src]
pub fn union<D>(self, other: D) -> Doc<'a, BoxDoc<'a, A>, A> where
D: Into<Doc<'a, BoxDoc<'a, A>, A>>,
[src]
D: Into<Doc<'a, BoxDoc<'a, A>, A>>,
impl<'a, T, A> Doc<'a, T, A>
[src]
pub fn render<'b, W: ?Sized>(&'b self, width: usize, out: &mut W) -> Result<()> where
T: Deref<Target = Doc<'b, T, A>>,
W: Write,
[src]
T: Deref<Target = Doc<'b, T, A>>,
W: Write,
Writes a rendered document to a std::io::Write
object.
pub fn render_fmt<'b, W: ?Sized>(&'b self, width: usize, out: &mut W) -> Result where
T: Deref<Target = Doc<'b, T, A>>,
W: Write,
[src]
T: Deref<Target = Doc<'b, T, A>>,
W: Write,
Writes a rendered document to a std::fmt::Write
object.
pub fn render_raw<'b, W: ?Sized>(
&'b self,
width: usize,
out: &mut W
) -> Result<(), W::Error> where
T: Deref<Target = Doc<'b, T, A>>,
W: RenderAnnotated<A>,
[src]
&'b self,
width: usize,
out: &mut W
) -> Result<(), W::Error> where
T: Deref<Target = Doc<'b, T, A>>,
W: RenderAnnotated<A>,
Writes a rendered document to a RenderAnnotated<A>
object.
pub fn pretty<'b>(&'b self, width: usize) -> Pretty<'b, T, A> where
T: Deref<Target = Doc<'b, T, A>>,
[src]
T: Deref<Target = Doc<'b, T, A>>,
Returns a value which implements std::fmt::Display
use pretty::Doc; let doc = Doc::<_>::group( Doc::text("hello").append(Doc::space()).append(Doc::text("world")) ); assert_eq!(format!("{}", doc.pretty(80)), "hello world");
impl<'a, T> Doc<'a, T, ColorSpec>
[src]
pub fn render_colored<'b, W>(&'b self, width: usize, out: W) -> Result<()> where
T: Deref<Target = Doc<'b, T, ColorSpec>>,
W: WriteColor,
[src]
T: Deref<Target = Doc<'b, T, ColorSpec>>,
W: WriteColor,
Trait Implementations
impl<'a, D: ?Sized, A> Into<Doc<'a, <D as DocAllocator<'a, A>>::Doc, A>> for DocBuilder<'a, D, A> where
D: DocAllocator<'a, A>,
[src]
D: DocAllocator<'a, A>,
impl<'a, T, A, S> From<S> for Doc<'a, T, A> where
S: Into<Cow<'a, str>>,
[src]
S: Into<Cow<'a, str>>,
impl<'a, T: Clone, A: Clone> Clone for Doc<'a, T, A>
[src]
impl<'a, T: Eq, A: Eq> Eq for Doc<'a, T, A>
[src]
impl<'a, T: Ord, A: Ord> Ord for Doc<'a, T, A>
[src]
fn cmp(&self, other: &Doc<'a, T, A>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a, T: PartialEq, A: PartialEq> PartialEq<Doc<'a, T, A>> for Doc<'a, T, A>
[src]
impl<'a, T: PartialOrd, A: PartialOrd> PartialOrd<Doc<'a, T, A>> for Doc<'a, T, A>
[src]
fn partial_cmp(&self, other: &Doc<'a, T, A>) -> Option<Ordering>
[src]
fn lt(&self, other: &Doc<'a, T, A>) -> bool
[src]
fn le(&self, other: &Doc<'a, T, A>) -> bool
[src]
fn gt(&self, other: &Doc<'a, T, A>) -> bool
[src]
fn ge(&self, other: &Doc<'a, T, A>) -> bool
[src]
impl<'a, T: Debug, A: Debug> Debug for Doc<'a, T, A>
[src]
impl<'a, T, A> StructuralPartialEq for Doc<'a, T, A>
[src]
impl<'a, T, A> StructuralEq for Doc<'a, T, A>
[src]
Auto Trait Implementations
impl<'a, T, A> Send for Doc<'a, T, A> where
A: Send,
T: Send,
A: Send,
T: Send,
impl<'a, T, A> Sync for Doc<'a, T, A> where
A: Sync,
T: Sync,
A: Sync,
T: Sync,
impl<'a, T, A> Unpin for Doc<'a, T, A> where
A: Unpin,
T: Unpin,
A: Unpin,
T: Unpin,
impl<'a, T, A> UnwindSafe for Doc<'a, T, A> where
A: UnwindSafe,
T: UnwindSafe,
A: UnwindSafe,
T: UnwindSafe,
impl<'a, T, A> RefUnwindSafe for Doc<'a, T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
A: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,