RFC: https://github.com/rust-lang/rfcs/pull/1432
This was originally tracked in #32310 as a combination of Vec::splice and String::splice, but the libs team decided to stabilize Vec::splice while keeping String::splice unstable and changing its signature in #44038.
The new signature has been implemented in #44044 but needs to go through FCP.
impl String {
pub fn splice<R>(&mut self, range: R, replace_with: &str)
where R: RangeArgument<usize>;
}
Ping @rust-lang/libs. FCP聽to stabilize?
I pushed for changing the signature so I will take responsibility for it. 馃樃
@rfcbot fcp merge
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed.
Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
As I mentioned in https://github.com/rust-lang/rust/issues/32310#issuecomment-324406220, I'm :-1: to this if the method is called splice() as it does not return the deleted part, unlike Vec::splice(). Calling it replace_slice() seems more appropriate.
(
replace, replaceInPlace, replacereplaceSubrange(_:with:). Other languages either provides the IndexAssign operator x[range] = replace_with (e.g. Ruby, Perl), doesn't have a method for this (e.g. C#), or doesn't have mutable string (e.g. Python, JavaScript, Go).
We already used replace() for something else, so we can't name it replace() unless we have RangeArgument<usize> extends Pattern.
)
replace_range?
I like replace_range.
:bell: This is now entering its final comment period, as per the review above. :bell:
The final comment period is now complete.
Help wanted: stabilization PR that also renames to replace_range.
Most helpful comment
As I mentioned in https://github.com/rust-lang/rust/issues/32310#issuecomment-324406220, I'm :-1: to this if the method is called
splice()as it does not return the deleted part, unlikeVec::splice(). Calling itreplace_slice()seems more appropriate.(
replace,replaceInPlace,replacereplaceSubrange(_:with:).Other languages either provides the IndexAssign operator
x[range] = replace_with(e.g. Ruby, Perl), doesn't have a method for this (e.g. C#), or doesn't have mutable string (e.g. Python, JavaScript, Go).We already used
replace()for something else, so we can't name itreplace()unless we haveRangeArgument<usize>extendsPattern.)