rust-lang / rust-lang/rust

Tracking Issue for `strip_circumfix`

Open
#147,946 4 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue disposition-merge finished-final-comment-period S-tracking-unimplemented T-libs
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.