Skip to content

Commit 354abf6

Browse files
committed
Add note about return yield EXPR
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.)
1 parent a021905 commit 354abf6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

text/3513-gen-blocks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ fn foo() -> impl Iterator<Item = ()> { gen {} }
229229

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

232+
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`.
233+
232234
# Prior art
233235
[prior-art]: #prior-art
234236

0 commit comments

Comments
 (0)