Open olson-sean-k opened 2 months ago
thanks for the feedback, just writing to tell you I did read the issue (the day you opened it) I just haven't found any time to work on it
I originally tried to avoid writing a custom drain as it either comes with performance penalties or unsafe code. Through I guess for use cases where the perf. penalty matters there is anyway reason not to use vec1 :shrug:
Vec1
does not uphold its non-empty guarantee in itsVec1::drain
API. Here's an example:This examples prints:
The API is still sound, because
vec1
does not useunsafe
code andVec1
APIs will panic if aVec1
is empty. 👍🏽 This is a niche situation and I think it's reasonable to accept this behavior as is for thevec1
crate! For what it's worth though, I believe this can be avoided by taking advantage of the non-empty guarantee and swapping items when the drain range is a prefix. See theSwapDrainSegment
implementation in themitsein
crate for an example (and theVec::drain
documentation).