A SmolStr
is a string type that has the following properties
size_of::<SmolStr>() == size_of::<String>()
\n
and space symbols (typical whitespace pattern of indentation
in programming laguages) do not use heap allocationsClone
is O(1)
Unlike String
, however, SmolStr
is immutable. The primary use-case for
SmolStr
is a good enough default storage for tokens of typical programming
languages. A specialized interner might be a better solution for some use-cases.
Intenrally, SmolStr
is roughly an enum { Heap<Arc<str>>, Inline([u8; 22]) }
.