Description
I've often needed to replace a sub-string within a String
in place with a new sub-string. If the new sub-string is smaller than the sub-string its replacing, that can be done in place without any allocations.
I don't know if this is the right place to fill in a "feature request", but there is only one correct efficient way to implement such a method, and an RFC feels overkill for that.
The only thing I don't know is how to name it. We could name it String::replace_in_place
and String::replacen_in_place
but... if the new string is larger than the one it is replacing then an allocation will happen, so "in place" isn't 100% accurate, unless we consider "in place" to mean that it happens on this String
, independently of whether it is reallocated or not.