Releases: bodil/smartstring
v1.0.1
FIXED
- To avoid an issue where allocated heap memory may be deallocated with a different layout alignment than it was officially allocated with when converting between
std::string::String
andSmartString
, even if otherwise correctly aligned, the respectiveFrom
implementations now usestd::alloc::Allocator::grow()
to re-align the heap data as necessary. An unfortunate consequence of this is that because thestd::alloc::Allocator
API hasn't been stabilised yet, unless you're on nightly or some future stable rustc version afterallocator_api
has been stabilised, converting betweenString
andSmartString
will always reallocate and copy (making it always O(n) rather than O(1) when correctly aligned and O(n) otherwise). (#28)
1.0.0
CHANGED
-
smartstring
now implements its own boxed string type rather than deferring directly toString
, so it no longer makes assumptions it shouldn't be making about the layout of theString
struct.This also allows us to organise the boxed struct in a way that will let us rely only on our basic assumption that heap memory is word aligned on both big and little endian architectures. The most immediate consequence of this is that
smartstring
will now compile on 32-bit big endian architectures such asmips
.We are now also explicitly allocating heap memory aligned for
u16
rather thanu8
, ensuring the assumption about pointer alignment becomes an invariant.In short:
smartstring
no longer relies on undefined behaviour, and should be safe to use anywhere. -
The above means that the boxed
SmartString
is no longer pointer compatible withString
, so if you were relying on that despite the documentation urging you not to, you'll really have to stop it now. Converting betweenSmartString
andString
usingFrom
andInto
traits is still efficient and allocation free. -
The minimum supported rustc version is now 1.57.0.
-
The
smartstring::validate()
function has been removed, as it's no longer needed.
0.2.10
CHANGED
- The minimum supported rustc version has been increased to 1.56.0, and the
rust-version
field has been added to the crate'sCargo.toml
to indicate the MSRV. (Therust-version
field itself was introduced in version 1.56, hence the bump.) - Dependencies have been bumped, most notably to
arbitrary
version 1.
0.2.9
0.2.8
CHANGED
- The minimum supported rustc version has been increased to 1.46.0.
ADDED
-
There are now
const fn new_const()
constructors forSmartString<Compact>
andSmartString<LazyCompact>
, added as a temporary measure because const functions can't yet take trait bounds on type arguments, so we can't simply makeSmartString::new()
const.Please note that when rustc catches up, the plan is to deprecate
new_const()
in favour ofnew()
. (#21)
0.2.7
0.2.6
0.2.5
0.2.3
ADDED
SmartString
now implementsDisplay
. (#6)SmartString
now implementsFromIterator<char>
.- Support for
serde
behind theserde
feature flag. (#2) - Support for
arbitrary
behind thearbitrary
feature flag. - Support for
proptest
behind theproptest
feature flag.
FIXED
SmartString::push_str
would previously trigger two heap allocations while promoting an inline string to a boxed string, one of which was unnecessary. It now only makes the one strictly necessary allocation. (#5)- Fixed a bug where
SmartString::remove
would panic if you tried to remove the last index in an inline string.