#stack #small-vec #string #optimization #small

no-std small_str

A String-like but using SmallVec internally

1 unstable release

0.1.0 Apr 22, 2024

#2284 in Algorithms

MIT license

54KB
769 lines

SmallStr

Crates.io API reference

A String-like but using SmallVec internally

  • SmallStr<N> == SmallVec<u8, N>
  • Clone is O(n)
  • Strings smaller than N bytes are allocated on the stack.
  • SmallString is an alias for SmallStr<16> and size_of::<SmallString>() == size_of::<String>() on 64-bit platform

Macro

macro format_smallstr! like format!

Traits

ToSmallStr like ToString, convert T: Display to SmallStr

pub trait ToSmallStr {
    fn to_smallstr<const N: usize>(&self) -> SmallStr<N>;
}

Dependencies

~105–265KB