3 ms·
Cow<'static, str> is exactly what you are asking for. In general the String type is not very good, and you should use something appropriate to your use of stri
by devit 5y ago
Cow<'static, str> is exactly what you are asking for.
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.
- TheGrassyKnoll 5y agoCOW == Copy on Write Its interesting that certain file systems use COW schemes: https://en.wikipedia.org/wiki/Btrfs