Skip to content

Releases

0.9.0

Choose a tag to compare

@github-actions github-actions released this 28 Nov 23:14

A rewrite of the crate around one generic type, Hip<E, R> (encoding ×
representation), with the old names kept as aliases. See
MIGRATION.md.

Added

  • comparisons generated from one table per family (== and <, both
    directions): inline values compare with the same std types as Hip values
    (arrays, Box, Cow, …); Hip and inline values order against each
    other; strings with OS strings, OS strings with paths, and bstr byte
    strings with bytes and strings, across Hip and inline values
  • systematic conversions (hipstr::convert): Hip::convert/try_convert
    (and to_converted/try_to_converted) change the family, the
    representation and the backend at once, keeping the buffer whenever the
    target can hold it (a uniquely owned buffer changes backend in place);
    generated From/TryFrom impls between every pair of families and of
    representations, by value and by reference; ConvertError gives the value
    back on failure
  • From<&Owned>, From<&mut Slice>, From<Rc<Slice>> and From<Arc<Slice>>
    for every family
  • inline values: const try_resize and widen, convert/try_convert
    between families; const Hip::try_to_inline, Hip::from_inline and
    Hip::try_from_inline, and TryFrom<Hip> by value
  • one Cargo feature per representation (hip, small, tiny) and per
    family (bytes, str, cstr, osstr, path, and the existing bstr),
    all enabled by default except bstr
  • 2-word (SmallStr, SmallByt, …) and 1-word (TinyStr, TinyByt, …)
    types for every family, beside the 3-word HipStr, HipByt, …
  • fixed-capacity inline types: InlineStr, InlineByt, InlineCStr,
    InlineBStr, InlineOsStr, InlinePath (inline::InlineStr<N> for any
    capacity up to 254 bytes): Copy, never allocating, with a const API
    (construction, accessors, push, push_str, pop, insert, remove,
    truncate, …) and try_ versions returning CapacityError
  • C strings: HipCStr, SmallCStr, TinyCStr (no_std), dereferencing to
    CStr without copy
  • bstr byte strings: HipBStr, SmallBStr, TinyBStr (bstr feature),
    dereferencing to bstr::BStr
  • std method parity: the Vec<u8> API on byte strings (insert, remove,
    drain, splice, extract_if, retain, dedup, resize, split_off,
    append, …), the String API on strings (insert_str, replace_range,
    retain, drain, split_off, from_utf16le, …), try_reserve,
    reserve_exact, into_boxed_*, leak, and the CString, OsString,
    PathBuf methods (push/pop/set_extension on paths, …)
  • std trait parity: DerefMut/AsMut/BorrowMut (copy-on-write) for bytes,
    strings and BStr; Add/AddAssign<&str>; owning and borrowing
    IntoIterator; io::Write; more Extend/FromIterator/From/TryFrom;
    From<_> for Box/Rc/Arc slices
  • faster inline construction: values are built word by word in registers
    (2–4× faster than the first rewrite, on par with 0.8 for 3 words and faster
    for 2 and 1 word)
  • const accessors (len, is_empty, as_ptr, as_str, as_slice, …) on
    every type
  • compat/LEDGER.md: every stable std method and its status, checked in CI
  • differential tests against Vec<u8> and String

Changed

  • breaking: the unstable feature, without effect since the backend trait
    was sealed, is removed
  • breaking: into_vec, into_string, into_os_string, into_path_buf
    are infallible (O(1) when the value uniquely owns an adopted buffer)
  • breaking: HipOsStr::to_str returns Option<&str> like std (the sharing
    conversion is into_str)
  • breaking: capacity() of a shared value is its length; heap capacities
    may be rounded up
  • breaking: with the bstr feature, HipByt no longer dereferences to
    BStr (feature-dependent Deref was not additive): use HipBStr, or
    AsRef<BStr>
  • breaking: public modules vecs, smart, common and the deprecated
    Local/ThreadSafe backend aliases removed; new public modules bstr,
    cstr, enc, hip, repr
  • MSRV 1.100, edition 2024; no more exposed provenance (Miri strict
    provenance clean)
  • the 2- and 1-word types keep only their own (thin) buffers: their heap
    reads are a pointer and a length (no header load nor kind check), and
    From<String>/From<Vec<u8>>/into_string/into_vec copy for them (the
    3-word types still adopt buffers)
  • shrink_to/shrink_to_fit shrink uniquely owned buffers in place
    (realloc) and leave shared ones alone, unless the value shows only part
    of the buffer (then copied, so that the rest can be freed)
  • split_off on 3-word values shares the buffer (O(1)) instead of copying
    the tail
  • into_vec (and the other into_*) copy only the visible bytes of a
    shortened or shared value
  • extract_if and String-style retain unshare the value once, not per
    element

Fixed

  • the docs.rs build: it failed since Rust 1.92 removed the doc_auto_cfg
    feature (0.8.1 has no docs on docs.rs)
  • loom is an optional dependency (loom feature, testing only): it no
    longer appears in the lock files of dependent crates (#52)
  • paths compared with Box<OsStr> compared bytes instead of paths
  • HipStr: Borrow<BStr> and HipPath: Borrow<OsStr> violated Borrow's
    contract (different hashes): removed
  • borsh deserialization pre-allocated the untrusted length prefix
  • HipOsStr::push (and Extend/FromIterator of OS strings) on Windows
    could build ill-formed WTF-8 from a surrogate pair split across the two
    strings: the pair is now joined, like OsString::push
  • reserve_exact/try_reserve_exact grew geometrically

0.8.2

Choose a tag to compare

@polazarus polazarus released this 28 Nov 22:54

Fixed

  • the docs.rs build, which failed since Rust 1.92 removed the doc_auto_cfg
    feature (0.8.1 has no docs on docs.rs)

Full changelog: 0.8.1...0.8.2 · crates.io

0.8.1

Choose a tag to compare

@polazarus polazarus released this 28 Nov 12:47

Soundness fix for 0.8; upgrade with cargo update -p hipstr.

Fixed

  • soundness: values with the thread-local Local (Rc) backend were
    Send, so a clone sent to another thread could race on the reference
    count (undefined behavior). They are no longer Send; use the default
    thread-safe types to share across threads. Reported and fixed by
    Ollie-Pearce in #54.

Yanked versions

Versions 0.5.0 to 0.8.0 (0.5.0, 0.5.1, 0.6.0, 0.7.0, 0.8.0) are affected and have been yanked from crates.io; 0.1.0 to 0.4.0 are not affected (Local was std's Rc, which is not Send).

  • 0.8 users: cargo update -p hipstr picks up 0.8.1.
  • 0.5, 0.6 and 0.7 users: there is no fixed version in those series; upgrade to 0.8.1. Existing lock files keep building, but a fresh resolution of hipstr = "0.5", "0.6" or "0.7" fails.

Full changelog: 0.8.0...0.8.1 · crates.io