From 7df3bf1860d1821056a5e9d4193b7e99d2c9479d Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 1 Feb 2016 11:52:00 -0500 Subject: [PATCH] make this example more obvious Fixes #31334 --- src/doc/book/loops.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/doc/book/loops.md b/src/doc/book/loops.md index 5b08c2fb04d..b5dde9be17f 100644 --- a/src/doc/book/loops.md +++ b/src/doc/book/loops.md @@ -125,7 +125,8 @@ Don't forget to add the parentheses around the range. #### On iterators: ```rust -# let lines = "hello\nworld".lines(); +let lines = "hello\nworld".lines(); + for (linenumber, line) in lines.enumerate() { println!("{}: {}", linenumber, line); } @@ -134,10 +135,8 @@ for (linenumber, line) in lines.enumerate() { Outputs: ```text -0: Content of line one -1: Content of line two -2: Content of line three -3: Content of line four +0: hello +1: world ``` ## Ending iteration early