Skip to content

Introduce String::remove_matches to remove all matches of a pattern in a string. #50206

Closed
@frewsxcv

Description

@frewsxcv

Like replace(..., ""), but doesn't result in any allocations.

I started implementing this in #50015 but got stuck, mainly because of limitations in the Pattern APIs.

let mut s = String::from("Trees are not green, the sky is not blue.");
s.remove_matches("not ");
assert_eq!("Trees are green, the sky is blue.", s);

This issue has been assigned to @jcotton42 via this comment.

Metadata

Metadata

Assignees

Labels

C-feature-requestCategory: A feature request, i.e: not implemented / a PR.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