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

Loosen the constraints of iterators #1

Open
inmaldrerah opened this issue Sep 19, 2023 · 0 comments
Open

Loosen the constraints of iterators #1

inmaldrerah opened this issue Sep 19, 2023 · 0 comments

Comments

@inmaldrerah
Copy link

The current iterator constraints are:

  • Have Self type
  • Have Item type
  • Have next method takes *Self and returns ?Item.

But I think the Self and Item types should not be enforced, as we can find them from the signature of the next method. Also, many iterators in the standard library do not have these two associated types, or have Self named in another way, e.g. std.bit_set.IntegerBitSet.Iterator.

Instead, we can define an iterator to be a type T that has a next function, taking one parameter of type *T and returns any value of optional type.

We can check this constraint with the domain and codomain functions in src/compat.zig.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant