Skip to content
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

Recommend IntoIterator over Iterator for argument types #598

Open
smoelius opened this issue Feb 3, 2023 · 0 comments
Open

Recommend IntoIterator over Iterator for argument types #598

smoelius opened this issue Feb 3, 2023 · 0 comments
Labels
good first issue Good for newcomers lint New lint or lint enhancement

Comments

@smoelius
Copy link
Collaborator

smoelius commented Feb 3, 2023

In most cases,* if a function requires an argument type to implement Iterator, the function could instead require the argument type to implement IntoIterator.

IntoIterator is implemented for types that implement Iterator. So the function would accept all the arguments it did before.

But, in addition, the function would accept things like slices, vectors, etc.

* The one exception I know of is when the Iterator bound is needed for another trait. Here is an example: https://github.com/trailofbits/necessist/blob/c17890cf085abbe1c376b75118c354c08f9a6d6f/core/src/core.rs#L406-L412

But for a first attempt, this lint could not fire whenever the type parameter appears in another trait bound.

@smoelius smoelius added the good first issue Good for newcomers label Feb 3, 2023
@smoelius smoelius added the lint New lint or lint enhancement label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers lint New lint or lint enhancement
Projects
None yet
Development

No branches or pull requests

1 participant