-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document what happens if std::iter::Take
's n
is greater than the amount of elements
#61222
Comments
Well I believe it is correct right now. It just returns the result of |
There's not really a notion I think of the amount of elements an iterator returns -- i.e., take will limit the amount of times let v = vec![1, 2];
let mut iter = v.into_iter().take(5);
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), None);
... |
Well, my problem (as a foreign speaker) is that the function is not called While within the iterator-logic the behavior is completely logical, for me in the first minutes it was not. |
Yep. I agree it is kinda weird |
@KizzyCode I made a PR for that, is the added explanation clear from you point of view ? |
…shtriplett Clarify the documentation of `take` This PR addresses the concerns of rust-lang#61222, adding an example for the behaviour of `Iterator::take` when there are less than `n` elements.
The PR fixing this has been merged, this could be closed. |
Closing as docs were updated. |
The documentation of
std::iter::Take
gives no information about what happens if the underlying iterator yields less elements thanTake
should take.Does it return less than
n
elements, does it panic, ...Maybe we should change
to something like
However english is not my mother tongue and I'm pretty sure there is a much better formulation than this (even to my ears this sounds clumsy)^^
The text was updated successfully, but these errors were encountered: