- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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, receiveSplicestruct.
- The String is exclusively borrowed and unusable.
- Process the replaced segment one char at a time.
- Drop the Splicestruct.
- 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 splicewhich eagerly does the replace and returns ().
- Drop the String and the replacement str (end of 'a and 'b).
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.