2021-07-06 11:26:35 +00:00
|
|
|
//! String related utilities.
|
|
|
|
|
2021-07-19 08:50:18 +00:00
|
|
|
pub fn strip_ascii_whitespace(line: &[u8]) -> &[u8] {
|
|
|
|
let line = match line.iter().position(|&b| !b.is_ascii_whitespace()) {
|
|
|
|
Some(n) => &line[n..],
|
|
|
|
None => return &[],
|
|
|
|
};
|
|
|
|
match line.iter().rev().position(|&b| !b.is_ascii_whitespace()) {
|
|
|
|
Some(n) => &line[..(line.len() - n)],
|
|
|
|
None => &[],
|
|
|
|
}
|
|
|
|
}
|