Rust: Tracking issue for String::splice

Created on 17 Sep 2017  路  9Comments  路  Source: rust-lang/rust

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>;
}
B-unstable C-tracking-issue T-libs final-comment-period

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, unlike Vec::splice(). Calling it replace_slice() seems more appropriate.

(

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.

)

All 9 comments

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:

  • [x] @BurntSushi
  • [x] @Kimundi
  • [x] @alexcrichton
  • [x] @aturon
  • [x] @dtolnay
  • [x] @sfackler

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.

(

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.

Was this page helpful?
0 / 5 - 0 ratings