You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The motivating example we had given for `gen` blocks admitted too easy
an implementation with existing stable iterator combinators. Let's
make the example more *motivating* by showing a simple algorithm,
run-length encoding, that's more difficult to implement in other ways.
(Thanks to Ralf Jung for pointing out the need for a better example.)
Copy file name to clipboardExpand all lines: text/3513-gen-blocks.md
+87-32Lines changed: 87 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -13,53 +13,108 @@ This RFC reserves the `gen` keyword in the Rust 2024 edition for generators and
13
13
14
14
Writing iterators manually can be painful. Many iterators can be written by chaining together iterator combinators, but some need to be written with a manual implementation of `Iterator`. This can push people to avoid iterators and do worse things such as writing loops that eagerly store values to mutable state. With `gen` blocks, we can now write a simple `for` loop and still get a lazy iterator of values.
15
15
16
-
By way of example, consider these ways of expressing the same function:
16
+
By way of example, consider these alternate ways of expressing [run-length encoding][]:
0 commit comments