#string #clone #byte #inline #buffer #optimized #size

no-std smol_buf

small-string optimized string / buffer type with O(1) clone

3 releases

0.1.2 Nov 15, 2024
0.1.1 Nov 15, 2024
0.1.0 May 12, 2024

#556 in Rust patterns

Download history 7/week @ 2024-09-20 12/week @ 2024-09-27 3/week @ 2024-10-04 215/week @ 2024-11-15 13/week @ 2024-11-22 11/week @ 2024-11-29 4/week @ 2024-12-06

243 downloads per month

MIT/Apache

45KB
1.5K SLoC

smol_buf

CI Crates.io API reference

The smol_buf crate offers the following types, each offering inline stack-allocated storage, and falling back to heap-allocation otherwise.

ty Deref Target size_of::<T> size_of::<Option<T>> inline bytes Clone
Str24 &str 24 24 23 O(1)
Str16 &str 16 16 15 O(1)
Buf24 &[u8] 24 24 23 O(1)
Buf16 &[u8] 16 16 15 O(1)

Unlike String and Vec, however, the types are immutable. They are thus replacements for Arc<str> and Arc<[u8]> respectively.

MSRV Policy

Minimal Supported Rust Version: latest stable.

Bumping MSRV is not considered a semver-breaking change.

Dependencies

~215KB