#string #no-std

no-std tinyvec_string

tinyvec based string types

8 releases

0.3.2 Jan 4, 2022
0.3.1 Jan 4, 2022
0.3.0 Jan 2, 2021
0.2.0 Dec 28, 2020
0.1.3 Jul 17, 2020

#1996 in Data structures

Download history 79/week @ 2024-01-04 532/week @ 2024-01-11 445/week @ 2024-01-18 267/week @ 2024-01-25 28/week @ 2024-02-01 2/week @ 2024-02-08 11/week @ 2024-02-15 22/week @ 2024-02-22 20/week @ 2024-02-29 31/week @ 2024-03-07 18/week @ 2024-03-14 9/week @ 2024-03-21 20/week @ 2024-03-28 17/week @ 2024-04-04 20/week @ 2024-04-11 23/week @ 2024-04-18

80 downloads per month
Used in sanitise-file-name

MIT/Apache

110KB
1.5K SLoC

crates.io docs.rs Tests

tinyvec_string

tinyvec based string types.

See the docs.rs documentation

tinyvec_string provides two string types:

  • ArrayString, a string backed by a fixed-size array on the stack, using ArrayVec
  • TinyString, a string backed by either a fixed-size array on the stack or a Vec on the heap

Features

Like tinyvec, tinyvec_string is no_std by default.

ArrayString has no dependencies (other than tinyvec and core).

TinyString requires the the alloc cargo feature to be enabled because it has a dependency on alloc:

[dependencies]
tinyvec_string = { version = "0.3.2", features = ["alloc"] }

Error types implement std::error::Error when the std feature is enabled.

The rustc_1_40 feature enables tinyvec's rustc_1_40 feature, which enables some optimizations for Rust versions >= 1.40.

The rustc_1_55 feature enables usage of const generics to allow usage of backing arrays of any size.

The rustc_1_57 feature enables TinyString::try_reserve and TinyString::try_reserve_exact.

Safety

This crate strives to be as safe as possible. Almost all internal unsafe code is copied verbatim from std's String implementation for maximum reliability and performance.

MSRV

Like tinyvec, tinyvec_string (without rustc version features) supports Rust 1.34+. The alloc feature requires Rust 1.36+.

Contributing

Feel free to open an issue if you have a problem, or open a pull request if you have a solution. Also feel free to reach me on the Rust Community Discord Server @ThatsNoMoon#0175.

License

tinyvec_string is dual-licensed under Apache-2.0 and MIT. Large sections of code, documentation, and tests were copied verbatim or copied and modified from rust-lang/rust; copyright for such content belongs to the original author.

Dependencies

~200–440KB
~14K SLoC