Closed ParkMyCar closed 8 months ago
retain()
should be ok, since it should invoke as_mut_buf
which already handle this https://github.com/ParkMyCar/compact_str/blob/df20a0148ecd5df509f82a20b12c45f77a45471e/compact_str/src/repr/mod.rs#L497
drain()
also calls as_mut_buf()
, so it should be ok.
insert()
calls reserve()
which handles this, so it should be also ok.
replace_range*()
calls as_mut_ptr()
or reserve()
(in replace_range_grow()
), so they should be ok.
@NobodyXu my bad 🤦♂️ you're totally right, thank you for looking into this! I updated the branch that adds fuzz coverage, will run it for a bit, and then release v0.8.0-beta
!
No worries! Better to be careful than rush to fix the bug later.
In the yet to be release API
CompactString::from_static_str
, you can create an instance ofCompactString
, backed by a&'static str
. There are a few APIs onCompactString
though that assume we own the underlying data, and thus modify it directly, e.g.retain()
drain()
insert_str()
replace_range()
We need to fix these APIs to copy the underlying data before modifying it