ReplaceNewlinesWithSpace

Trait ReplaceNewlinesWithSpace 

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

To extend types which implement AsRef<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<'_, 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).

Implementors§