mirror of https://github.com/rust-lang/rfcs
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:
parent
a02190547f
commit
354abf6626
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue