Feature gate: #![feature(byte_slice_trim_ascii)]
This is a tracking issue for ASCII trim functions on byte slices.
Public API
The feature adds three new methods to byte slices ([u8]):
const fn trim_ascii_start(&self) -> &[u8]: Remove leading ASCII whitespace
const fn trim_ascii_end(&self) -> &[u8]: Remove trailing ASCII whitespace
const fn trim_ascii(&self) -> &[u8]: Remove leading and trailing ASCII whitespace
For deciding what bytes to treat as whitespace, u8::is_ascii_whitespace is used. See the linked docs for more details.
Examples:
assert_eq!(b" \t hello world\n".trim_ascii_start(), b"hello world\n");
assert_eq!(b"\r hello world\n ".trim_ascii_end(), b"\r hello world");
assert_eq!(b"\r hello world\n ".trim_ascii(), b"hello world");
Steps / History
Unresolved Questions
Feature gate:
#![feature(byte_slice_trim_ascii)]This is a tracking issue for ASCII trim functions on byte slices.
Public API
The feature adds three new methods to byte slices (
[u8]):const fn trim_ascii_start(&self) -> &[u8]: Remove leading ASCII whitespaceconst fn trim_ascii_end(&self) -> &[u8]: Remove trailing ASCII whitespaceconst fn trim_ascii(&self) -> &[u8]: Remove leading and trailing ASCII whitespaceFor deciding what bytes to treat as whitespace,
u8::is_ascii_whitespaceis used. See the linked docs for more details.Examples:
Steps / History
Unresolved Questions
stras well?