-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 connection between Iterator::skip and Iterator::nth #60223
Comments
A section about "you should consider overloading these things" definitely sounds good. |
Your forum link is broken. |
The docs do say
However, I do like @scottmcm 's suggestion, about talking about which methods you may want to override. |
Such hints should be non-normative though to allow the implementations, especially specializations, to use different approaches in the future. |
Agreed, @the8472. I was picturing more which methods to consider overloading, not specifically which things use them. (Or, contrapositively, which things there's usually no reason to overload, like |
So basically this issue is about adding some documentation on which methods you might want to override right? Which methods do you think are best to mention? Or did I misinterpret the discussion? |
@DevQps That's correctly, probably under or near https://doc.rust-lang.org/nightly/std/iter/index.html#implementing-iterator. For now my inclination would be to mention |
What about adding this line of text at the end of the "Implementing Iterator" section?
Feel free to adjust the text or make something up yourself :) If you agree I will create a PR for this. |
I think it would also be nice to add something to the
|
@jhwgh1968 Sorry for the late reply! I apparently don't get notifications for thumbs ups and the like! I will hopefully be able to create a PR somewhere this midday. |
…-Simulacrum Updated the Iterator docs with information about overriding methods. # Description Updated the Iterator docs with information about overriding methods. closes rust-lang#60223
From my forum question:
It's easy, according to @scottmcm: implement my own
Iterator::nth
method, and I will get askip
implementation for free.In retrospect it makes sense, but it was not obvious to me at all just from reading the docs. It is not mentioned in the Implementing Iterators section of the API, or the docs for either method. And as the link in my post suggests, trying to work my way around the ownership of the APIs led me quite far afield.
Admittedly it's not the most common case, but I think it would save others time if the standard library at least mentioned this somewhere.
EDIT: fixed forum link which changed its name when I marked it solved.
The text was updated successfully, but these errors were encountered: