by devit · 5y ago · 0 comments
In general the String type is not very good, and you should use something appropriate to your use of strings for any string that is used more than a constant times in your program, which can be, for instance:
- String
- Box<[str]>
- Cow<'static, str>
- Cow<'a, str>
- Interned strings
- Rc<[str]> or Arc<[str]>
- A rope data structure
In fact I think putting String in the standard library might have been a mistake since it's almost always a suboptimal choice for anything except string builders in local variables.
Its interesting that certain file systems use COW schemes:
https://en.wikipedia.org/wiki/Btrfs