Skip to content

Commit 3b5d71e

Browse files
author
Novotnik, Petr
committed
Make .enumerate() example self-explanatory
1 parent 34d7f7e commit 3b5d71e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/doc/book/loops.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@ When you need to keep track of how many times you already looped, you can use th
105105
#### On ranges:
106106

107107
```rust
108-
for (i, j) in (5..10).enumerate() {
109-
println!("i = {} and j = {}", i, j);
108+
for (index, value) in (5..10).enumerate() {
109+
println!("index = {} and value = {}", index, value);
110110
}
111111
```
112112

113113
Outputs:
114114

115115
```text
116-
i = 0 and j = 5
117-
i = 1 and j = 6
118-
i = 2 and j = 7
119-
i = 3 and j = 8
120-
i = 4 and j = 9
116+
index = 0 and value = 5
117+
index = 1 and value = 6
118+
index = 2 and value = 7
119+
index = 3 and value = 8
120+
index = 4 and value = 9
121121
```
122122

123123
Don't forget to add the parentheses around the range.

0 commit comments

Comments
 (0)