pub enum TrailingNewline {
Preserve,
Strip,
Ensure,
}Expand description
Trailing-newline policy applied at the document boundary.
Preserve (the default) matches the source’s trailing-newline
shape: if the source ends with one or more \n bytes, the
formatted output ends with exactly one \n; if the source has no
trailing \n, the output has none either. This is what
formatter validation needs to hold: pulldown-cmark’s HTML render of
\t\x10 is <pre><code>\x10</code></pre> while its
render of \t\x10\n is <pre><code>\x10\n</code></pre>; the
trailing LF lives inside the code body for any document ending in
an indented code block. An unconditional “ensure trailing \n”
post-pass cannot avoid that class of HTML-divergence; Preserve
avoids it by construction.
Strip drops every trailing \n. Ensure forces exactly one
trailing \n (the pre-Preserve trailing_newline = true
behaviour); kept under an explicit name so callers opt in to the
foot-gun rather than getting it by default.
Variants§
Preserve
Match the source: one trailing \n iff the source had any.
Strip
Drop every trailing \n.
Ensure
Force exactly one trailing \n, appending if absent.
Trait Implementations§
Source§impl Clone for TrailingNewline
impl Clone for TrailingNewline
Source§fn clone(&self) -> TrailingNewline
fn clone(&self) -> TrailingNewline
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TrailingNewline
impl Debug for TrailingNewline
Source§impl Default for TrailingNewline
impl Default for TrailingNewline
Source§fn default() -> TrailingNewline
fn default() -> TrailingNewline
Source§impl PartialEq for TrailingNewline
impl PartialEq for TrailingNewline
Source§fn eq(&self, other: &TrailingNewline) -> bool
fn eq(&self, other: &TrailingNewline) -> bool
self and other values to be equal, and is used by ==.