-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Add String::replace_first and String::replace_last
#134316
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
Conversation
|
I don't think I see any libs-api feedback on the other thread, and that is from a while back anyway. Could you file an ACP for this at https://github.com/rust-lang/libs-team/issues? |
|
These methods would be convenient but I feel like they should probably come with an in-place |
This comment has been minimized.
This comment has been minimized.
|
ACP opened: rust-lang/libs-team#506 @rustbot label S-waiting-on-ACP I added |
|
☔ The latest upstream changes (presumably #135286) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@zachs18 |
This is still waiting on the ACP |
|
@bors r+ rollup ACP approved, PR approved. Might be interested in the proposed |
|
@bors r- r=me when the conflicts are fixed. |
|
Please also squash when you rebase, this PR has fixup commits |
Rebased and modified by zachs18. Co-authored-by: zachs18 <[email protected]>
0243f5c to
8ed7fca
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot ready |
| // | ||
| // Library features: | ||
| // tidy-alphabetical-start | ||
| #![cfg_attr(not(no_global_oom_handling), feature(string_replace_in_place))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw I think you may as well drop the cfg_attr and enable the feature unconditionally, usually we don't gate these too strictly. And we'll wind up using it elsewhere anyway.
I'll merge after PR CI finishes, with or without this (just ping me once it does if I miss it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might actually be needed (?), since its absence seems to be what the failed CI job is complaining about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah; I'm sorry, this was bad advice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I undid this (that is, undid removing cfg_attr, so re-added it) and re-pushed
@rustbot ready
8ed7fca to
271b10c
Compare
This comment has been minimized.
This comment has been minimized.
|
Thanks! I assume the GCC failure is spurious @bors r=joshtriplett ,tgross35 |
|
@bors rollup |
…base, r=joshtriplett Add `String::replace_first` and `String::replace_last` Rebase of rust-lang#97977 (cc `@WilliamVenner)` > Convenience methods that use `match_indices` and `replace_range` to efficiently replace a substring in a string without reallocating, if capacity (and the implementation of `Vec::splice`) allows. The intra-doc link to `str::replacen` is a direct url-based link to `str::replacen` in `std`'s docs to work around rust-lang#98941. This means that when building only `alloc`'s docs (and not `std`'s), it will be a broken link. There is precedent for this e.g. in [`core::hint::spin_loop`](https://doc.rust-lang.org/nightly/src/core/hint.rs.html#214) which links to `std::thread::yield_now` using a [url-based link](https://github.com/rust-lang/rust/blob/master/library/core/src/hint.rs#L265) and thus is a dead link when only building `core`'s docs. ACP: rust-lang/libs-team#506
|
The GCC job failed again in rollup: #148010 (comment) @bors r- |
271b10c to
8ed7fca
Compare
|
@bors r=joshtriplett ,tgross35 |
Rollup merge of #134316 - zachs18:string_replace_in_place_rebase, r=joshtriplett Add `String::replace_first` and `String::replace_last` Rebase of #97977 (cc `@WilliamVenner)` > Convenience methods that use `match_indices` and `replace_range` to efficiently replace a substring in a string without reallocating, if capacity (and the implementation of `Vec::splice`) allows. The intra-doc link to `str::replacen` is a direct url-based link to `str::replacen` in `std`'s docs to work around #98941. This means that when building only `alloc`'s docs (and not `std`'s), it will be a broken link. There is precedent for this e.g. in [`core::hint::spin_loop`](https://doc.rust-lang.org/nightly/src/core/hint.rs.html#214) which links to `std::thread::yield_now` using a [url-based link](https://github.com/rust-lang/rust/blob/master/library/core/src/hint.rs#L265) and thus is a dead link when only building `core`'s docs. ACP: rust-lang/libs-team#506
Rollup of 3 pull requests Successful merges: - rust-lang/rust#134316 (Add `String::replace_first` and `String::replace_last`) - rust-lang/rust#147713 (Retire ast::TyAliasWhereClauses.) - rust-lang/rust#148011 (Revert constification of `AsRef for Cow` due to inference failure ) r? `@ghost` `@rustbot` modify labels: rollup
Rebase of #97977 (cc @WilliamVenner)
The intra-doc link to
str::replacenis a direct url-based link tostr::replaceninstd's docs to work around #98941. This means that when building onlyalloc's docs (and notstd's), it will be a broken link. There is precedent for this e.g. incore::hint::spin_loopwhich links tostd::thread::yield_nowusing a url-based link and thus is a dead link when only buildingcore's docs.ACP: rust-lang/libs-team#506