Tracking Issue for `strip_circumfix`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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: rust-lang/libs-team#680
- Implementation: #147947
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the public API and the completed implementation in #147947, then read the stabilization guidance linked in the issue. Check the unresolved question about whether the feature is too niche and verify the required release-cycle and FCP conditions. Done means opening or completing the stabilization PR once no blocking concerns remain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100