Enum pretty::Doc
[−]
[src]
pub enum Doc<'a, A, B> { Nil, Append(B, B), Group(B), Nest(usize, B), Space, Newline, Text(Cow<'a, str>), Annotated(A, B), }
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 B
parameter is used to abstract over pointers to Doc
. See RefDoc
and BoxDoc
for how
it is used
Variants
Nil
Append(B, B)
Group(B)
Nest(usize, B)
Space
Newline
Text(Cow<'a, str>)
Annotated(A, B)
Methods
impl<'a, A, B> Doc<'a, A, B>
[src]
pub fn render<'b, W: ?Sized>(&'b self, width: usize, out: &mut W) -> Result<()> where
B: Deref<Target = Doc<'b, A, B>>,
W: Write,
[src]
B: Deref<Target = Doc<'b, A, B>>,
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
B: Deref<Target = Doc<'b, A, B>>,
W: Write,
[src]
B: Deref<Target = Doc<'b, A, B>>,
W: Write,
Writes a rendered document to a std::fmt::Write
object.
pub fn pretty<'b>(&'b self, width: usize) -> Pretty<'b, A, B> where
B: Deref<Target = Doc<'b, A, B>>,
[src]
B: Deref<Target = Doc<'b, A, B>>,
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, B> Doc<'a, ColorSpec, B>
[src]
pub fn render_colored<'b, W>(&'b self, width: usize, out: W) -> Result<()> where
B: Deref<Target = Doc<'b, ColorSpec, B>>,
W: WriteColor,
[src]
B: Deref<Target = Doc<'b, ColorSpec, B>>,
W: WriteColor,
impl<'a, A, B> Doc<'a, A, B>
[src]
pub fn nil() -> Doc<'a, A, B>
[src]
An empty document.
pub fn as_string<T: ToString>(t: T) -> Doc<'a, A, B>
[src]
The text t.to_string()
.
The given text must not contain line breaks.
pub fn newline() -> Doc<'a, A, B>
[src]
A single newline.
pub fn text<T: Into<Cow<'a, str>>>(data: T) -> Doc<'a, A, B>
[src]
The given text, which must not contain line breaks.
pub fn space() -> Doc<'a, A, B>
[src]
A space.
impl<'a, A> Doc<'a, A, BoxDoc<'a, A>>
[src]
pub fn append(
self,
that: Doc<'a, A, BoxDoc<'a, A>>
) -> Doc<'a, A, BoxDoc<'a, A>>
[src]
self,
that: Doc<'a, A, BoxDoc<'a, A>>
) -> Doc<'a, A, BoxDoc<'a, A>>
Append the given document after this document.
pub fn concat<I>(docs: I) -> Doc<'a, A, BoxDoc<'a, A>> where
I: IntoIterator<Item = Doc<'a, A, BoxDoc<'a, A>>>,
[src]
I: IntoIterator<Item = Doc<'a, A, BoxDoc<'a, A>>>,
A single document concatenating all the given documents.
pub fn intersperse<I, S>(docs: I, separator: S) -> Doc<'a, A, BoxDoc<'a, A>> where
I: IntoIterator<Item = Doc<'a, A, BoxDoc<'a, A>>>,
S: Into<Doc<'a, A, BoxDoc<'a, A>>> + Clone,
A: Clone,
[src]
I: IntoIterator<Item = Doc<'a, A, BoxDoc<'a, A>>>,
S: Into<Doc<'a, A, BoxDoc<'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 group(self) -> Doc<'a, A, BoxDoc<'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, A, BoxDoc<'a, A>>
[src]
Increase the indentation level of this document.
pub fn annotate(self, ann: A) -> Doc<'a, A, BoxDoc<'a, A>>
[src]
Trait Implementations
impl<'a, A: Clone, B: Clone> Clone for Doc<'a, A, B>
[src]
fn clone(&self) -> Doc<'a, A, B>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a, A: Debug, B: Debug> Debug for Doc<'a, A, B>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a, A: Eq, B: Eq> Eq for Doc<'a, A, B>
[src]
impl<'a, A: Ord, B: Ord> Ord for Doc<'a, A, B>
[src]
fn cmp(&self, __arg_0: &Doc<'a, A, B>) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<'a, A: PartialEq, B: PartialEq> PartialEq for Doc<'a, A, B>
[src]
fn eq(&self, __arg_0: &Doc<'a, A, B>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Doc<'a, A, B>) -> bool
[src]
This method tests for !=
.
impl<'a, A: PartialOrd, B: PartialOrd> PartialOrd for Doc<'a, A, B>
[src]
fn partial_cmp(&self, __arg_0: &Doc<'a, A, B>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Doc<'a, A, B>) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Doc<'a, A, B>) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Doc<'a, A, B>) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Doc<'a, A, B>) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<'a, A, B, S> From<S> for Doc<'a, A, B> where
S: Into<Cow<'a, str>>,
[src]
S: Into<Cow<'a, str>>,
impl<'a, A, D: ?Sized> Into<Doc<'a, A, D::Doc>> for DocBuilder<'a, A, D> where
D: DocAllocator<'a, A>,
[src]
D: DocAllocator<'a, A>,