Tracking Issue for `str::replace_with`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(replace_with)]
This is a tracking issue for the implementation of replace_with and replacen_with for the String type in standart library, followed from the ACP (https://github.com/rust-lang/libs-team/issues/344#issuecomment-3404030290).
This feature adds str::replace_with as an augmentation of str::replace and str::replacen_with as an augmentation of str:replacen to the standard library. Compared to the current versions, these functions allow for passing an f: impl FnMut(&str) -> S that can be used to produce replacements dynamically as well as to insert custom computations such as counting the number of changes.
Public API
// str::replace_with
fn replace_with<P: Pattern, S: AsRef<str>>(
&self,
from: P,
f: impl FnMut(&str) -> S,
) -> String;
// str::replacen_with
fn replacen_with<P: Pattern, S: AsRef<str>>(
&self,
from: P,
f: impl FnMut(&str) -> S,
count: usize
) -> String;
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- ACP: rust-lang/libs-team#344
- Implementation: https://github.com/rust-lang/rust/pull/147741
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- None yet.
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
Read the proposed str::replace_with and str::replacen_with signatures, then review the linked implementation PR rust-lang/rust#147741 and the ACP discussion. The remaining tracking steps are the final comment period and a stabilization PR; done means those lifecycle steps have been completed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100