What should a collection do if someone tries to extend it beyond it's capacity and it cannot grow the capacity?
major options seem to be:
2) Drop the rest of the iterator items
This doesn't have to get added to the official docs, I'd just like to know general opinion at the moment.
ArrayVec simply drops the rest of the iterator.
I think this does need to go into the official docs for the
I had been leaning towards "panic" for my own ArrayVec type in the
tinyvec crate. That is what it currently does.
It felt consistent to panic because all the other ways to add elements will cause a panic on overflow.
Panicking seems like a better option to me as well
Dropping the rest of the elements seems highly unexpected
The program will silently continue until you get a logic error sometime later :/
If someone needs this to be fallible, then we can always add a
TryExtend API, similar to how
try_extend_from_slice. It could have a an iterator-based
try_extend method even if there’s no
TryExtend trait in the standard library.