pub enum Doc<'a, T, A = ()> {
Nil,
Append(T, T),
Group(T),
Nest(usize, T),
Space,
Newline,
Text(Cow<'a, str>),
Annotated(A, T),
}
Expand description
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§
Implementations§
Source§impl<'a, T, A> Doc<'a, T, A>
impl<'a, T, A> Doc<'a, T, A>
Source§impl<'a, A> Doc<'a, BoxDoc<'a, A>, A>
impl<'a, A> Doc<'a, BoxDoc<'a, A>, A>
Sourcepub fn append<D>(self, that: D) -> Doc<'a, BoxDoc<'a, A>, A>
pub fn append<D>(self, that: D) -> Doc<'a, BoxDoc<'a, A>, A>
Append the given document after this document.
Sourcepub fn concat<I>(docs: I) -> Doc<'a, BoxDoc<'a, A>, A>
pub fn concat<I>(docs: I) -> Doc<'a, BoxDoc<'a, A>, A>
A single document concatenating all the given documents.
Sourcepub fn intersperse<I, S>(docs: I, separator: S) -> Doc<'a, BoxDoc<'a, A>, A>
pub fn intersperse<I, S>(docs: I, separator: S) -> Doc<'a, BoxDoc<'a, A>, A>
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]
.
Sourcepub fn group(self) -> Doc<'a, BoxDoc<'a, A>, A>
pub fn group(self) -> Doc<'a, BoxDoc<'a, A>, A>
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.
Sourcepub fn nest(self, offset: usize) -> Doc<'a, BoxDoc<'a, A>, A>
pub fn nest(self, offset: usize) -> Doc<'a, BoxDoc<'a, A>, A>
Increase the indentation level of this document.
pub fn annotate(self, ann: A) -> Doc<'a, BoxDoc<'a, A>, A>
Source§impl<'a, T, A> Doc<'a, T, A>
impl<'a, T, A> Doc<'a, T, A>
Sourcepub fn render<'b, W>(&'b self, width: usize, out: &mut W) -> Result<()>
pub fn render<'b, W>(&'b self, width: usize, out: &mut W) -> Result<()>
Writes a rendered document to a std::io::Write
object.
Sourcepub fn render_fmt<'b, W>(&'b self, width: usize, out: &mut W) -> Result
pub fn render_fmt<'b, W>(&'b self, width: usize, out: &mut W) -> Result
Writes a rendered document to a std::fmt::Write
object.
Sourcepub fn render_raw<'b, W>(
&'b self,
width: usize,
out: &mut W,
) -> Result<(), W::Error>
pub fn render_raw<'b, W>( &'b self, width: usize, out: &mut W, ) -> Result<(), W::Error>
Writes a rendered document to a RenderAnnotated<A>
object.
Trait Implementations§
Source§impl<'a, D, A> Into<Doc<'a, <D as DocAllocator<'a, A>>::Doc, A>> for DocBuilder<'a, D, A>where
D: ?Sized + DocAllocator<'a, A>,
impl<'a, D, A> Into<Doc<'a, <D as DocAllocator<'a, A>>::Doc, A>> for DocBuilder<'a, D, A>where
D: ?Sized + DocAllocator<'a, A>,
Source§impl<'a, T: Ord, A: Ord> Ord for Doc<'a, T, A>
impl<'a, T: Ord, A: Ord> Ord for Doc<'a, T, A>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a, T: PartialOrd, A: PartialOrd> PartialOrd for Doc<'a, T, A>
impl<'a, T: PartialOrd, A: PartialOrd> PartialOrd for Doc<'a, T, A>
impl<'a, T: Eq, A: Eq> Eq for Doc<'a, T, A>
impl<'a, T, A> StructuralPartialEq for Doc<'a, T, A>
Auto Trait Implementations§
impl<'a, T, A> Freeze for Doc<'a, T, A>
impl<'a, T, A> RefUnwindSafe for Doc<'a, T, A>where
T: RefUnwindSafe,
A: RefUnwindSafe,
impl<'a, T, A> Send for Doc<'a, T, A>
impl<'a, T, A> Sync for Doc<'a, T, A>
impl<'a, T, A> Unpin for Doc<'a, T, A>
impl<'a, T, A> UnwindSafe for Doc<'a, T, A>where
T: UnwindSafe,
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)