As far as I can tell nobody in this thread was really concerned about the removal (or private) of as_mut_vec. No one has evidence that this method is used often or in important ways. Is that correct?
And we also agree that this method can be replaced with other unsafe methods like from_raw_parts without doing much additional work (with the little exception when a SSO string needs to convert to a normal string first)., right?
And we agree that keeping this method would limit the ability to change the implementation of the string type which could (or could not) be a problem in the future.
So I don’t really see any reason to keep it.
But I read and thought about another idea that was mentioned somewhere. I am really not sure if this is useful, but I think it would be a pretty flexible solution.
We separate the “String” into two parts: Buffer and UTF8-Wrapper. We would have an trait called StringBuf (for example) and a type UTF8Wrapper<B: StringBuf>. The wrapper ensures that everything stays UTF8 by using the methods specified in the StringBuf interface. The string module would consists of the wrapper type, a few special string buffers (like SSO) and this type alias:
type String = UTF8Wrapper<Vec>; // or UTF8Wrapper<SSOBuf>
I really like the idea. But to really use this some things needs to be clear:
- Is there enough time to make such a big change?
- Is it possible to do that without loss in performance?
- Would the trait
StringBuf allow the implementation by a immutable string buffer?
So: I really think we should at least remove as_mut_vec and maybe think of another even better solution.