#string #small-string

no-std smallstr

String-like container based on smallvec

4 releases (2 breaking)

0.3.1 Aug 13, 2025
0.3.0 Mar 12, 2022
0.2.0 Jan 17, 2020
0.1.0 Apr 26, 2018

#50 in Data structures

Download history 57947/week @ 2025-08-19 50850/week @ 2025-08-26 50114/week @ 2025-09-02 53423/week @ 2025-09-09 35661/week @ 2025-09-16 51616/week @ 2025-09-23 52923/week @ 2025-09-30 53856/week @ 2025-10-07 59464/week @ 2025-10-14 60879/week @ 2025-10-21 63041/week @ 2025-10-28 61688/week @ 2025-11-04 67056/week @ 2025-11-11 68349/week @ 2025-11-18 56795/week @ 2025-11-25 61528/week @ 2025-12-02

263,345 downloads per month
Used in 312 crates (42 directly)

MIT/Apache

37KB
869 lines

Implements SmallString, a String-like container for small strings

no_std support

By default, smallstr does not depend on std. The std feature may be enabled to add the std dependency. The ffi feature also implies std.

ffi feature

The ffi feature will add the following trait implementations to SmallString:

  • PartialEq<OsStr>
  • PartialEq<&'_ OsStr>
  • PartialEq<OsString>
  • PartialEq<Cow<'_, OsString>>

This feature also adds std as a dependency.

serde support

When the serde feature is enabled, the traits serde::Deserialize and serde::Serialize are implemented for SmallString.

This feature is disabled by default.

By default, the serde dependency is compiled with no_std. If the std feature is enabled, std is added as a dependency in serde, as well.

union feature

This feature will enable the union feature in smallvec, which reduces the size of a SmallString instance. This feature requires Rust 1.49 or newer.


smallstr

String-like container based on SmallVec

Documentation

Building

To include smallstr in your project, add the following to your Cargo.toml:

[dependencies]
smallstr = "0.3"

License

smallstr is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Dependencies

~240KB