whatwg_infra::strings

Function trim_ascii_whitespace

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

Removes ASCII whitespace from before and after a string.

See also: WHATWG Infra Standard definition

ยงExamples

use whatwg_infra::trim_ascii_whitespace;

let s1 = "     ";
assert_eq!(trim_ascii_whitespace(s1), String::from(""));

let s2 = "  cats and dogs  ";
assert_eq!(trim_ascii_whitespace(s2), String::from("cats and dogs"));