We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Go 1.23 introduced support for iterators. This allows code to define functions that supply values for Go's for range syntax.
for range
Adding an optional flag for generating iterators would be a non-breaking change that allows for a more ergonomic way to visit all items in a vector.
Code such as
var weapon sample.Weapon for i := 0; i < monster.WeaponsLength(); i++ { monster.Weapons(&weapon, i) ... }
could be instead written as
for i, weapon := range monster.WeaponsIter() { ... }
This would be accomplished via generated code that appears as follows (or similar):
func (rcv *Monster) WeaponsIter() iter.Seq2 { var weapon Weapon return func(yield func(i int, v *Weapon)) { for i := 0; i < rcv.WeaponsLength(); i++ { rcv.Weapon(i, &weapon) yield(i, &weapon) } } }
I can author a PR if this feature would be acceptable.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Go 1.23 introduced support for iterators. This allows code to define functions that supply values for Go's
for range
syntax.Adding an optional flag for generating iterators would be a non-breaking change that allows for a more ergonomic way to visit all items in a vector.
Code such as
could be instead written as
This would be accomplished via generated code that appears as follows (or similar):
I can author a PR if this feature would be acceptable.
The text was updated successfully, but these errors were encountered: