Repository navigation
Releases
Releases · polazarus/hipstr
0.9.0
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 asHipvalues
(arrays,Box,Cow, …);Hipand inline values order against each
other; strings with OS strings, OS strings with paths, andbstrbyte
strings with bytes and strings, acrossHipand inline values - systematic conversions (
hipstr::convert):Hip::convert/try_convert
(andto_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);
generatedFrom/TryFromimpls between every pair of families and of
representations, by value and by reference;ConvertErrorgives the value
back on failure From<&Owned>,From<&mut Slice>,From<Rc<Slice>>andFrom<Arc<Slice>>
for every family- inline values:
consttry_resizeandwiden,convert/try_convert
between families;constHip::try_to_inline,Hip::from_inlineand
Hip::try_from_inline, andTryFrom<Hip>by value - one Cargo feature per representation (
hip,small,tiny) and per
family (bytes,str,cstr,osstr,path, and the existingbstr),
all enabled by default exceptbstr - 2-word (
SmallStr,SmallByt, …) and 1-word (TinyStr,TinyByt, …)
types for every family, beside the 3-wordHipStr,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 aconstAPI
(construction, accessors,push,push_str,pop,insert,remove,
truncate, …) andtry_versions returningCapacityError - C strings:
HipCStr,SmallCStr,TinyCStr(no_std), dereferencing to
CStrwithout copy bstrbyte strings:HipBStr,SmallBStr,TinyBStr(bstrfeature),
dereferencing tobstr::BStr- std method parity: the
Vec<u8>API on byte strings (insert,remove,
drain,splice,extract_if,retain,dedup,resize,split_off,
append, …), theStringAPI on strings (insert_str,replace_range,
retain,drain,split_off,from_utf16le, …),try_reserve,
reserve_exact,into_boxed_*,leak, and theCString,OsString,
PathBufmethods (push/pop/set_extensionon paths, …) - std trait parity:
DerefMut/AsMut/BorrowMut(copy-on-write) for bytes,
strings andBStr;Add/AddAssign<&str>; owning and borrowing
IntoIterator;io::Write; moreExtend/FromIterator/From/TryFrom;
From<_>forBox/Rc/Arcslices - 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) constaccessors (len,is_empty,as_ptr,as_str,as_slice, …) on
every typecompat/LEDGER.md: every stable std method and its status, checked in CI- differential tests against
Vec<u8>andString
Changed
- breaking: the
unstablefeature, 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_strreturnsOption<&str>like std (the sharing
conversion isinto_str) - breaking:
capacity()of a shared value is its length; heap capacities
may be rounded up - breaking: with the
bstrfeature,HipBytno longer dereferences to
BStr(feature-dependentDerefwas not additive): useHipBStr, or
AsRef<BStr> - breaking: public modules
vecs,smart,commonand the deprecated
Local/ThreadSafebackend aliases removed; new public modulesbstr,
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_veccopy for them (the
3-word types still adopt buffers) shrink_to/shrink_to_fitshrink 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_offon 3-word values shares the buffer (O(1)) instead of copying
the tailinto_vec(and the otherinto_*) copy only the visible bytes of a
shortened or shared valueextract_ifandString-styleretainunshare 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 (
loomfeature, 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>andHipPath: Borrow<OsStr>violatedBorrow's
contract (different hashes): removed- borsh deserialization pre-allocated the untrusted length prefix
HipOsStr::push(andExtend/FromIteratorof OS strings) on Windows
could build ill-formed WTF-8 from a surrogate pair split across the two
strings: the pair is now joined, likeOsString::pushreserve_exact/try_reserve_exactgrew geometrically
0.8.2
0.8.1
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 longerSend; 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 hipstrpicks 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