3 ms·
> Yet the standard library's HashMap and BTreeMap are very sophisticated. "Sophistication" isn't really the argument I'm making, though I can see how you may t
by steveklabnik 4y ago
> Yet the standard library's HashMap and BTreeMap are very sophisticated.
"Sophistication" isn't really the argument I'm making, though I can see how you may think that. I should have said something more like "when a tradeoff isn't clear, you shouldn't make it, by default, for everyone." Because that's the issue here: it's not clear that SSO is universally an advantage. So forcing that on everyone isn't the right way to go, in my opinion. Reasonable people may differ, of course :)
(It's also because this wouldn't end up enforcing SSO on String, but on all Vecs. While SSO is often useful for strings, it may not be for every vector that exists, so you'd also have to take that into consideration.)
> could just come with a warning in the documentation that calling it will force the string into its heap-allocated form.
If you made that change, it would then conflict with the name of the method: as_ is defined as a free conversion.
- mwcampbell 4y ago> If you made that change, it would then conflict with the name of the method: as_ is defined as a free conversion. Ah, I wasn't aware of that convention. I'm sure that means I failed to do adequate research before jumping into this discussion.
- steveklabnik 4y agoIt's all good :) I think that may be a bit harsh on yourself. If you're curious: https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv https://rust-lang.github.io/api-guidelines/naming.html#ad-ho...