Closed
Description
As discussed in #32310, it is never necessary to look at the return value of String::splice. Applying the splice eagerly is always simpler and at least as efficient.
- fn splice<R>(&'a mut self, range: R, replace_with: &'b str) -> Splice<'a, 'b>;
+ fn splice<R>(&mut self, range: R, replace_with: &str);
With a return value:
- The String and the replacement str are in scope (start of 'a and 'b).
- Call
splice
, receiveSplice
struct. - The String is exclusively borrowed and unusable.
- Process the replaced segment one char at a time.
- Drop the
Splice
struct. - Drop the String and the replacement str (end of 'a and 'b, must happen after 5).
Without a return value;
- The String and the replacement str are in scope (start of 'a and 'b).
- Grab the soon replaced segment &s[range].
- The String is shared borrowed but otherwise usable.
- Process the soon replaced segment one char at a time or as an ordinary &str.
- Call
splice
which eagerly does the replace and returns (). - Drop the String and the replacement str (end of 'a and 'b).