-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: String::replace_in_place #56415
Comments
Writing up a PR would be a good way to see the specifics and let T-libs see if they want it for the standard library or not. |
Yep! That's the plan. :) I mostly just created this issue as a reminder for myself, considering how as I said a tracking issue would be needed anyway. |
Somewhat similar, I opened an issue earlier this year for |
I think that |
@frewsxcv or @clarfon, are you planning on working this feature? I'm interested in getting it done too. |
I'm not planning to work it |
I don't have time at the moment but I'm fine with someone else picking it up. Will modify the OP. |
Essentially, this can avoid allocating extra memory under the condition that the replacement is smaller than the searched expression. If the replacement is larger, a
VecDeque<u8>
can be kept to minimise the amount of extra bytes allocated. We could also pre-allocate an array on the stack and do some sort ofSmallVecDeque
.Having a
String::replace_in_place
could also allow aCow::replace_in_place
which only allocates a new string if there's a change.I don't have the time for this but I figured I'd post this here anyway, as a tracking issue will be needed anyway.
The text was updated successfully, but these errors were encountered: