| Crates.io | lstring |
| lib.rs | lstring |
| version | 2.0.2 |
| created_at | 2025-05-21 15:03:50.369326+00 |
| updated_at | 2025-05-21 15:03:50.369326+00 |
| description | Key String: optimized for map keys |
| homepage | |
| repository | https://github.com/katyo/kstring |
| max_upload_size | |
| id | 1683488 |
| size | 149,060 |
Key String: Optimized for map keys.
This crate is extended and more feature rich version of kstring with some significant changes.
Internal representation of string types still is same so you can convert corresponding types between both crates (see kstring feature).
Considerations:
Ramifications:
&'static str across strings (KString),
references (KStringRef), and lifetime abstractions (KStringCow) to avoid
allocating for struct field names.Box<str> rather than String to use less memory.Significant changes:
From<&'static str> is unsound it changed to From<&str>.
To instantiate from static str use KString::from_static instead of From::from
(or [kstring] macro).KStringBase and KStringCowBase which renamed
to KString and KStringCow. Corresponding type aliases is removed.
To instantiate types with default backend wrap it with angle brackets
(KString::from_ref("abc") => <KString>::from_ref("abc")).KStringWriter and kformat macros. Also added FromIterator trait implsfrom_utf8 and from_utf16 functions.Features:
max_inline: Instead of aligning the inline-string for performance (15 bytes + length on 64-bit), use the full width (22 bytes on 64-bit)
arc: Instead of using Box<str>, use Arc<str>. Note: allocations are fast enough that this can actually slow things down for small enough strings.
serde: Enables serde support (Adds Serialize/Deserialize traits impls).
quote: Enables quote support (Adds ToTokens trait impls).
diesel: Enables diesel support (Adds ToSql/FromSql traits impls).
kstring: Enables conversion from/into corresponding kstring types.
Alternatives, see rust-string-comparison and string-benchmarks-rs.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.