-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Add String::replace_first and String::replace_last
#97977
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
Add String::replace_first and String::replace_last
#97977
Conversation
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (or someone else) soon. Please see the contribution instructions for more information. |
|
For now I have manually specified the types in the test and doctest, but these should of course be omitted once the issue is resolved. |
|
@rustbot label +T-libs-api -T-libs |
This comment has been minimized.
This comment has been minimized.
004561b to
eb1fa3c
Compare
This comment has been minimized.
This comment has been minimized.
|
@WilliamVenner FYI: when a PR is ready for review, send a message containing @rustbot author |
|
@WilliamVenner @rustbot label: +S-inactive |
|
??? This is blocked by #98941 @JohnCSimon |
|
@WilliamVenner sorry - my mistake, reopened. |
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #93455) made this pull request unmergeable. Please resolve the merge conflicts. |
|
https://github.com/zachs18/rust/tree/string_replace_in_place_rebase |
85d91c6 to
8dd1b5e
Compare
|
@zachs18 Thank you 🙂 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@rustbot label: -S-blocked |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
☔ The latest upstream changes (presumably #130674) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@WilliamVenner |
|
@WilliamVenner |
…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
…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
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
Convenience methods that use
match_indicesandreplace_rangeto efficiently replace a substring in a string without reallocating, if capacity (and the implementation ofVec::splice) allows.