#thin #string #box #no-std

no-std thin_str

A string type that’s smaller than Box<str> or String

1 unstable release

0.1.0 Jan 16, 2020

#2243 in Rust patterns

Download history 8/week @ 2024-07-22 19/week @ 2024-07-29 13/week @ 2024-08-05 11/week @ 2024-08-12 11/week @ 2024-08-19 24/week @ 2024-08-26 14/week @ 2024-09-02 16/week @ 2024-09-09 7/week @ 2024-09-16 389/week @ 2024-09-23 662/week @ 2024-09-30 1293/week @ 2024-10-07 1139/week @ 2024-10-14 1886/week @ 2024-10-21 2727/week @ 2024-10-28 728/week @ 2024-11-04

6,490 downloads per month
Used in hunt

MIT/Apache

18KB
425 lines

thin_str: A rust crate for a single-pointer string

Docs CircleCI

ThinStr is the slimmer sibling of Box<str> and String. It's a single (nonnull) pointer, and stores it's length inline with the data, in the same allocation.

Limitations

Right now the interface is minimally feature-complete, and relies on Deref<Target = str> for most of it, but patches are welcome to flesh it out more.

In particular, while it isn't immutable, it might as well be, since it cannot currently be resized after construction. This will probably eventually change, but it will likely always be much more like Box<str> rather than like String.

Crate features

This crate is currently no_std compatible in all configurations, however it uses extern crate alloc as you might expect.

  • serde_support: Support serializing and deserializing ThinStr using serde. Disabled by default.

License

MIT/Apache2

Dependencies

~160KB