I noticed an API inconsistency. ArrayVec::push panics if you overflow the capacity, but ArrayVec::extend silently drops elements if you overflow the capacity.
I prefer the panicking behavior, since otherwise you run the risk of accidentally losing iterator elements. imo that's not an intuitive failure mode. I'd suggest changing extend to panic on overflow, and introduce a fallible try_extend (after all, you already have try_extend_from_slice), try_from_iterator, and probably try_collect and a trait to go with it.
This is a breaking change. The migration path would be pretty straightforward:
// previous version
arrayvec.extend(iterator);
// next version
arrayvec.extend(iterator.take(arrayvec.remaining_capacity());
// -- OR --
let _ignore_result = arrayvec.try_extend(iterator);
I noticed an API inconsistency.
ArrayVec::pushpanics if you overflow the capacity, butArrayVec::extendsilently drops elements if you overflow the capacity.I prefer the panicking behavior, since otherwise you run the risk of accidentally losing iterator elements. imo that's not an intuitive failure mode. I'd suggest changing
extendto panic on overflow, and introduce a fallibletry_extend(after all, you already havetry_extend_from_slice),try_from_iterator, and probablytry_collectand a trait to go with it.This is a breaking change. The migration path would be pretty straightforward: