Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
STC
A modern, user friendly, generic, type-safe and fast C99 container library: String, Vector, Sorted and Unordered Map and Set, Deque, Forward List, Smart Pointers, Bitset and Random numbers. (by stclib)
Along with performance improvements, this release includes implementing multiple methods for CompactString, to bring its API nearly 1:1 with String. The only exception being methods that don't have a direct port for a small string optimization, e.g. into_bytes, or methods that aren't yet stable. A full change log can be found here.
SmolStr can online 22 characters and is immutable, but it is atomically ref counted so cloning is O(1). A good comparison of different string types can be found here
Very cool! I have a similar implementation in C where max stack/short string length is 23 characters, as C strings need a null-terminator. The last byte represents length as 23 - len, so when len is 23, it doubles as the null terminator (and it's high bit as the sso discriminator).
Related posts
- Announcing `compact_str` version 0.7! A small string optimization for Rust
- Is there a type like `std::num::NonZero*` but for other values than zero?
- Announcing `compact_str` version 0.5! A small string optimization for Rust
- Announcing `compact_str` version 0.4! A small string optimization for Rust
- Inlined string (in ~200 LOC)