whatwg_infra::strings

Function strip_newlines

Source
pub fn strip_newlines(s: &str) -> String
Expand description

A string without any U+000A LINE FEED (LF) or U+000D CARIAGE RETURN (CR) codepoints.

See also: WHATWG Infra Standard definition

ยงExamples

use whatwg_infra::strip_newlines;

let s = "Alice\n\rBob";
assert_eq!(strip_newlines(s), String::from("AliceBob"));

let empty = "\r\r\n\n\r\n";
assert_eq!(strip_newlines(empty), String::from(""));