Skip to main content

NormalizeNewlines

Trait NormalizeNewlines 

Source
pub trait NormalizeNewlines<'a> {
    // Required method
    fn normalize_newlines(self) -> Cow<'a, str>;
}
Available on crate feature alloc only.
Expand description

To extend str and Cow<str> to have normalize_newlines method.

This converts Unicode newline sequences to LF (\n) while avoiding allocation when the text is already normalized.

Required Methods§

Source

fn normalize_newlines(self) -> Cow<'a, str>

Returns a Cow<str> where newline sequences are normalized to LF (\n).

Handles LF, VT, FF, CRLF, CR, NEL, LS, and PS. CRLF is treated as one newline sequence.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a> NormalizeNewlines<'a> for &'a str

Source§

impl<'a> NormalizeNewlines<'a> for Cow<'a, str>

Implementors§