Skip to content

Tracking Issue for str::replace_with #147731

@alpaylan

Description

@alpaylan

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 (rust-lang/libs-team#344 (comment)).

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.)

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions