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

feedback #2

Merged
merged 10 commits into from
Oct 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
intro
  • Loading branch information
shepmaster committed Oct 12, 2023
commit 1b5dcd4a48f12fb483749c92e919f659b0c85aa5
11 changes: 6 additions & 5 deletions text/0000-gen-fn.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
# Summary
[summary]: #summary

Add `gen {}` blocks to the language. These blocks implement `Iterator` and
enable writing iterators in regular code by `yield`ing elements instead of having
to implement `Iterator` for a custom struct and manually writing an `Iterator::next`
method body. This is a change similar to adding `async {}` blocks that implement
`Future` instead of having to manually write futures and their state machines.
Add `gen {}` blocks to the language. These implement `Iterator` by `yield`ing
elements. This is simpler and more intuitive than creating a custom type and
manually implementing `Iterator` for that type, which requires writing an
explicit `Iterator::next` method body. This is a change similar to adding `async
{}` blocks that implement `Future` instead of having to manually write futures
and their state machines.

Furthermore, add `gen fn` to the language. `gen fn foo(arg: X) -> Y` desugars to
`fn foo(arg: X) -> impl Iterator<Item = Y>`.
Expand Down