Add static string variant
Kestrer opened this issue · comments
Kestrer commented
Add a new variant which contains a &'static str
to allow easily creating a smol str at compile time.
jD91mZM2 commented
Why? SmolStr::new
is probably already constified as a part of optimization - so there wouldn't be a performance benefit. Maybe it should be explicitly marked as a const
function though, in order to be able to use it in constants (if that's your goal)
Alex Kladov commented
Yeah, I've just released 0.1.17
with const fn new_inline(text: &str) -> SmolStr
. If you need to handle long const stirng, I suggest sticking with just &'static str
, or maybe wrapping SmolStr
into once_cell::Lazy
.