pub enum LineEnding {
Lf,
Crlf,
}Expand description
The line terminator a buffer was loaded with.
Variants§
Lf
\n. The default for a new or newline-free file on every platform,
including Windows — a file TYPE creates has no existing convention to
honour, and LF is what the tools around it emit.
Crlf
\r\n.
Implementations§
Source§impl LineEnding
impl LineEnding
Sourcepub fn detect(text: &str) -> Self
pub fn detect(text: &str) -> Self
Detect from a file’s contents.
The first terminator decides. A mixed file is not a third kind of file: whatever line one did is what the file is, and it is what gets written back. Taking a majority instead would mean a save that silently rewrites every line break in somebody’s file because the count went the other way.
A lone \r is not a line ending. Classic Mac endings died with Mac OS 9
and a stray carriage return inside a line is far likelier, so treating
one as a terminator would misread an ordinary file badly.
Trait Implementations§
Source§impl Clone for LineEnding
impl Clone for LineEnding
Source§fn clone(&self) -> LineEnding
fn clone(&self) -> LineEnding
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more