-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-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(strip_circumfix)]
This is a tracking issue for adding the strip_circumfix method to str and the slice primitives.
These methods are a shorter and more concise way to express these prevalent patterns that appear in a lot of code:
if let Some(a) = a.strip_prefix('<') && let Some(a) = a.strip_suffix('>') {}
// or...
let a = a.strip_prefix('<').and_then(|a| a.strip_suffix('>'));Public API
impl str {
pub fn strip_circumfix<P: Pattern, S: Pattern>(&self, prefix: P, suffix: S) -> Option<&str>
where
for<'a> S::Searcher<'a>: ReverseSearcher<'a>;
}
impl<T> [T] {
pub fn strip_circumfix(&self, prefix: &P, suffix: &S) -> Option<&[T]>
where
P: SlicePattern<Item = T> + ?Sized,
S: SlicePattern<Item = T> + ?Sized,
T: PartialEq;
}Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- ACP:
{str|slice}::strip_circumfixlibs-team#680 - Implementation: Implement
strip_circumfixlib feature #147947 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Is this too niche? https://hackmd.io/-3EwglvOR2W-jXGyPEoUXQ#new-change-proposal-rusttflibs680-strslicestrip_affixes
Footnotes
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-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-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.