-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRStatus: This is ready to stabilize; it may need a stabilization report and a PRT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Feature gate: #![feature(trim_prefix_suffix)]
This is a tracking issue for adding trim_prefix
and trim_suffix
methods to str
that remove at most one occurrence of a specified prefix or suffix while always returning a string slice (rather than Option<&str>
), enabling easy method chaining.1
Public API
impl str {
pub fn trim_prefix<P>(&self, prefix: P) -> &str
where
P: Pattern;
pub fn trim_suffix<P>(&self, suffix: P) -> &str
where
P: Pattern,
for<'a> P::Searcher<'a>: ReverseSearcher<'a>;
}
Steps / History
(Remember to update the S-tracking-*
label when checking boxes.)
- Implementation: Add
trim_prefix
andtrim_suffix
methods for bothslice
andstr
types. #142331 - Final comment period (FCP)2
- Stabilization PR
Unresolved Questions
- None yet.
Footnotes
Scripter17Scripter17Scripter17Scripter17Scripter17
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRStatus: This is ready to stabilize; it may need a stabilization report and a PRT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.