Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize str_strip feature #72466

Merged
merged 1 commit into from
May 29, 2020
Merged

Conversation

tesuji
Copy link
Contributor

@tesuji tesuji commented May 22, 2020

This PR stabilizes these APIs:

impl str {
    /// Returns a string slice with the prefix removed.
    ///
    /// If the string starts with the pattern `prefix`, `Some` is returned with the substring where
    /// the prefix is removed. Unlike `trim_start_matches`, this method removes the prefix exactly
    /// once.
    pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str>;

    /// Returns a string slice with the suffix removed.
    ///
    /// If the string ends with the pattern `suffix`, `Some` is returned with the substring where
    /// the suffix is removed. Unlike `trim_end_matches`, this method removes the suffix exactly
    /// once.
    pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str>
    where
        P: Pattern<'a>,
        <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>;
}

Closes #67302

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 22, 2020
@jonas-schievink jonas-schievink added relnotes Marks issues that should be documented in the release notes of the next release. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels May 22, 2020
@jonas-schievink jonas-schievink added this to the 1.45 milestone May 22, 2020
@sfackler
Copy link
Member

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented May 23, 2020

Team member @sfackler has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels May 23, 2020
@withoutboats
Copy link
Contributor

neither the stabilization PR nor the tracking issue have any description of the API to be stabilized, we should try to be better about documenting these features than this

@tesuji
Copy link
Contributor Author

tesuji commented May 23, 2020

Ok I am sorry. I updated the PR description.

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels May 23, 2020
@rfcbot
Copy link

rfcbot commented May 23, 2020

🔔 This is now entering its final comment period, as per the review above. 🔔

@dtolnay
Copy link
Member

dtolnay commented May 28, 2020

@bors r+

@bors
Copy link
Contributor

bors commented May 28, 2020

📌 Commit 2df69ba has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 28, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this pull request May 28, 2020
Stabilize str_strip feature

This PR stabilizes these APIs:

```rust
impl str {
    /// Returns a string slice with the prefix removed.
    ///
    /// If the string starts with the pattern `prefix`, `Some` is returned with the substring where
    /// the prefix is removed. Unlike `trim_start_matches`, this method removes the prefix exactly
    /// once.
    pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str>;

    /// Returns a string slice with the suffix removed.
    ///
    /// If the string ends with the pattern `suffix`, `Some` is returned with the substring where
    /// the suffix is removed. Unlike `trim_end_matches`, this method removes the suffix exactly
    /// once.
    pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str>
    where
        P: Pattern<'a>,
        <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>;
}
```

Closes  rust-lang#67302
bors added a commit to rust-lang-ci/rust that referenced this pull request May 29, 2020
Rollup of 12 pull requests

Successful merges:

 - rust-lang#72239 (Implement PartialOrd and Ord for SocketAddr*)
 - rust-lang#72466 (Stabilize str_strip feature)
 - rust-lang#72605 (Add working example for E0617 explanation)
 - rust-lang#72636 (Cleanup `Resolver::<clone|into>_outputs` methods)
 - rust-lang#72645 (Add myself to .mailmap)
 - rust-lang#72667 (expand unaligned_references test)
 - rust-lang#72670 (Fix incorrect comment in generator test)
 - rust-lang#72674 (Clippy should always build)
 - rust-lang#72682 (Add test for rust-lang#66930)
 - rust-lang#72695 (update data layout for illumos x86)
 - rust-lang#72697 (Remove rustc-ux-guidelines)
 - rust-lang#72702 (rustc_lint: Remove `unused_crate_dependencies` from the `unused` group)

Failed merges:

r? @ghost
@bors bors merged commit 3bcf697 into rust-lang:master May 29, 2020
@tesuji tesuji deleted the stabilize_str-strip branch May 29, 2020 06:09
@rfcbot rfcbot added the finished-final-comment-period The final comment period is finished for this PR / Issue. label Jun 2, 2020
@rfcbot rfcbot removed the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Jun 2, 2020
tesuji pushed a commit to tesuji/rustc that referenced this pull request Jun 4, 2020
Stabilize str_strip feature

This PR stabilizes these APIs:

```rust
impl str {
    /// Returns a string slice with the prefix removed.
    ///
    /// If the string starts with the pattern `prefix`, `Some` is returned with the substring where
    /// the prefix is removed. Unlike `trim_start_matches`, this method removes the prefix exactly
    /// once.
    pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str>;

    /// Returns a string slice with the suffix removed.
    ///
    /// If the string ends with the pattern `suffix`, `Some` is returned with the substring where
    /// the suffix is removed. Unlike `trim_end_matches`, this method removes the suffix exactly
    /// once.
    pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str>
    where
        P: Pattern<'a>,
        <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>;
}
```

Closes  rust-lang#67302
@dtolnay dtolnay self-assigned this Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tracking issue for strip_prefix, strip_suffix for str
8 participants