| Crates.io | inline_flexstr |
| lib.rs | inline_flexstr |
| version | 0.1.5 |
| created_at | 2025-12-23 01:23:22.740064+00 |
| updated_at | 2025-12-24 01:25:59.500286+00 |
| description | A simple to use, copy/clone-efficient inline string type for Rust |
| homepage | |
| repository | https://github.com/nu11ptr/flexstr/inline_flexstr |
| max_upload_size | |
| id | 2000570 |
| size | 132,936 |
A simple to use, copy/clone-efficient inline string type for Rust
A fast inline string crate. Essentially it never allocates on the heap, but is limited currently to strings that are 2 bytes less than 3 machine words in length (10 bytes on 32-bit, 22 bytes on 64-bit). It is generic over all the Rust string types (str, CStr, OsStr, Path, [u8]).
CopyString (3 words wide, even inside an Option)serde/sqlx optional for serialization/deserialization/encode/decodeno_stdsafe feature that forbids any unsafe usage
OsStr/Path support on Windows requires at least one unsafe call (win_min_unsafe feature).str, CStr, OsStr, Path, [u8])forbid(unsafe_code) (performance penalty)sqlx feature)std (default)serde dependency and adds serialization/deserializationOsStr/Path. No other string types or operating systems are impacted (implies safe feature).
safe feature is enabledosstr and/or path feature(s) are enabledstr-based strings (default)[u8])CStr-based stringsOsStr-based stringsPath-based strings (implies osstr feature)use inline_flexstr::*;
let hello: InlineStr = "hello".try_into().expect("string too long");
let world: InlineCStr = c"world!".try_into().expect("string too long");
println!("{hello} {world:?}");
In general, it performs quite well given that it is mostly just a thin wrapper over the stdlib. See the benchmarks page for more details.
The code was written by hand with care (although AI tab completion was used). Any contributions should be completely understood by the contributor, whether AI assisted or not.
The tests on the otherhand were 90%+ generated by AI under my instruction. I've done a cursory review for sanity, but they need more work. Volunteers welcome.
This is currently experimental, however, I will be using this at a startup in production code, so it will become production ready at some point.
Contributions are welcome so long as they align to my vision for this crate. Currently, it does most of what I want it to do (outside of string construction and mutation, but I'm not ready to start on that yet).
This project is licensed optionally under either: