New crate `zcheapstr` is out! zvariant has provided a `Str` type for many years ...
Zeeshan Ali Khan :rust: πΊπ¦ @zeenix@toot.cat
New crate `zcheapstr` is out!
zvariant has provided a `Str` type for many years now and given it's general usefulness, it's always been my plan to split it into a separate crate of its own. Now that has finally happened.
`Str` (now called `CheapStr`), is similar to the Cow<'_, str> type, but it:
* is specialized for strings.
* treats `&'static str` as a separate type. This allows you to avoid allocations and copying when turning a `CheapStr` instance created from a `&'static str` into an owned version in generic code that doesn't/can't assume the inner lifetime of the source `CheapStr` instance.
* stores owned strings in an `Arc`, so `Clone` never copies or allocates: it either copies a reference or increments a reference count.
* is immutable. Consequently, unlike `Cow`, it is not a copy-on-write type: there is no way to get a mutable reference to the underlying string.
Fetch it from https://crates.io/crates/zcheapstr