The std function
iter.take(n) produces an iterator which takes
n elements from
Except, that's not what
takes does -- it limits the length of the iterator to
n, but it may still return fewer elements if iter did not have
n elements to produce.
I personally usually want
n elements, and less would be a serious error. Therefore I suggest
take_exactly, which produces
n elements, or panics if less than
n elements are contained in
Having a quick look around on github, I see many places where users are assuming they will get exactly
n elements from the iterator when using
take. It might be all those pieces of code are correct, but if not these pieces of code will silently truncate, rather than give an out-of-bounds (like you would get if you indexed an array out of bounds).