ReplaceNewlinesWithSpace

Trait ReplaceNewlinesWithSpace 

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

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

This can be useful when you need to normalize multiline strings into a single line for logging, database storage, or display purposes.

Required Methods§

Source

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

Returns a Cow<str> where all newline sequences are replaced with a space.

Replaces Windows-style newlines (\r\n), old Mac-style (\r), and Unix-style (\n).

Implementations on Foreign Types§

Source§

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

Source§

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

Implementors§