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.)
This commit is contained in:
Travis Cross 2024-03-29 05:43:52 +00:00
parent a02190547f
commit 354abf6626
1 changed files with 2 additions and 0 deletions

View File

@ -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