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
Generators should implement either Iterator or IntoIterator. #60062
Comments
I've experiment with this in the past, and also talked to @Nemo157 about this. An interesting point is, do you allow panic's to happen? Your implementation does panic when Another interesting point is, what to do with generators that are |
I don't have a problem with a panic occurring if I've seen the |
This is my position as well, but when discussing it on the community Discord there was a lot of pushback against it. The common opinion appears to be that the |
@Nemo157 To be fair, the
|
@DutchGhost That looks like a good approach to me. I actually quickly hacked together something similar myself in the past. What do you mean about making an iterator out of Either way, I think we definitely need this in the stdlib, just needs a bit more planning first. |
If we had pin_cell in std then it could look like:
|
Generators (currently unstable) are used as an implementation detail for async/await support in rust, but they can also be useful for writing Iterators and similar.
If you want to turn a Generator into an Iterator, you must wrap it in a new type, but it'd be useful to implement Iterator directory on Generator.
Here's an example of how that could work:
The text was updated successfully, but these errors were encountered: