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

no-std small_str

A String-like but using SmallVec internally

1 unstable release

0.1.0 Apr 22, 2024

#958 in Algorithms

Download history 163/week @ 2024-04-22

163 downloads per month

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

~100–275KB