The CI error in #321 is actually an implementation error. Once a CompactString gets so big that its capacity cannot be stored inline anymore, it will always be at least this big. This PR lets shrink_to() allocate a new Repr with a capacity that can be inlined.
To facilitate this change I made allocations and re-allocations fallible. As an added bonus better panic messages will be generated, mentioning the calling locations of the failing (re)allocations. And the user gets two new methods, try_with_capacity() and try_reserve, to manually handle out-of-memory cases.
The CI error in #321 is actually an implementation error. Once a CompactString gets so big that its capacity cannot be stored inline anymore, it will always be at least this big. This PR lets
shrink_to()
allocate a newRepr
with a capacity that can be inlined.To facilitate this change I made allocations and re-allocations fallible. As an added bonus better panic messages will be generated, mentioning the calling locations of the failing (re)allocations. And the user gets two new methods,
try_with_capacity()
andtry_reserve
, to manually handle out-of-memory cases.