pub enum Document<'a> {
}Variants§
String(&'a str)
Array(Vec<Document<'a>>)
Indent(Vec<Document<'a>>)
Increase the level of indentation.
IndentIfBreak(IndentIfBreak<'a>)
Group(Group<'a>)
Mark a group of items which the printer should try to fit on one line. This is the basic command to tell the printer when to break. Groups are usually nested, and the printer will try to fit everything on one line, but if it doesn’t fit it will break the outermost group first and try again. It will continue breaking groups until everything fits (or there are no more groups to break).
Line(Line)
Specify a line break. If an expression fits on one line, the line break will be replaced with a space. Line breaks always indent the next line with the current level of indentation.
LineSuffix(Vec<Document<'a>>)
This is used to implement trailing comments.
It’s not practical to constantly check where the line ends to avoid accidentally printing some code at the end of a comment.
lineSuffix buffers docs passed to it and flushes them before any new line.
LineSuffixBoundary
IfBreak(IfBreak<'a>)
Print something if the current group or the current element of fill breaks and something else if it doesn’t.
Fill(Fill<'a>)
This is an alternative type of group which behaves like text layout:
it’s going to add a break whenever the next element doesn’t fit in the line anymore.
The difference with group is that it’s not going to break all the separators, just the ones that are at the end of lines.
BreakParent
Include this anywhere to force all parent groups to break.
Align(Align<'a>)
Trim(Trim)
Trim all newlines from the end of the document.
DoNotTrim
Do not perform any trimming before printing the next document.
Implementations§
Trait Implementations§
Source§impl<'a> Ord for Document<'a>
impl<'a> Ord for Document<'a>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a> PartialOrd for Document<'a>
impl<'a> PartialOrd for Document<'a>
impl<'a> Eq for Document<'a>
impl<'a> StructuralPartialEq for Document<'a>
Auto Trait Implementations§
impl<'a> Freeze for Document<'a>
impl<'a> RefUnwindSafe for Document<'a>
impl<'a> Send for Document<'a>
impl<'a> Sync for Document<'a>
impl<'a> Unpin for Document<'a>
impl<'a> UnwindSafe for Document<'a>
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more