Skip to content

Commit

Permalink
Add note about return yield EXPR
Browse files Browse the repository at this point in the history
Under this RFC, it's possible to yield one last value concisely with
`return yield EXPR`.  Let's make a note of that.

(Thanks to Nemo157 for pointing this out and to pnkfelix for
suggesting that this be noted in the RFC.)
  • Loading branch information
traviscross committed Mar 29, 2024
1 parent a021905 commit 354abf6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions text/3513-gen-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ fn foo() -> impl Iterator<Item = ()> { gen {} }

...should be, as it could reasonably be either `std::iter::once(())` or `std::iter::empty::<()>()`.

Note that, under this RFC, because `return` within `gen` blocks accepts an argument of type `()` and `yield` within `gen` blocks returns the `()` type, it is possible to yield one last element concisely with `return yield EXPR`.

# Prior art
[prior-art]: #prior-art

Expand Down

0 comments on commit 354abf6

Please sign in to comment.