Closed
Description
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 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
- Implementation: core: Implement ASCII trim functions on byte slices #93686
- Final comment period (FCP)
- Stabilization PR
Unresolved Questions
- Should the methods be made const by using a pattern matching approach instead of indexing?
- Should corresponding methods be added to
str
as well?
Metadata
Metadata
Assignees
Labels
Area: UnicodeCategory: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the library API team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.Marks issues that should be documented in the release notes of the next release.