Skip to content

Commit 4a3c66e

Browse files
committed
---
yaml --- r: 212215 b: refs/heads/tmp c: 151c3d3 h: refs/heads/master i: 212213: beffc27 212211: 3616c06 212207: bef2628 v: v3
1 parent 05ee4bf commit 4a3c66e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: 62e70d35be3fe532c26a400b499c58a18f18dd3a
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: 6e2f18ef322c094ed49eee11994fc49c5cacbc2a
35+
refs/heads/tmp: 151c3d3644c2d8b21465dd8a48ad753539e18c88
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: b77d60adb019bb5de05e884a99f3290ec4694137
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/src/doc/trpl/for-loops.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,41 @@ Rust does not have the “C-style” `for` loop on purpose. Manually controlling
4242
each element of the loop is complicated and error prone, even for experienced C
4343
developers.
4444

45-
# Loopcounter
45+
# Enumerate
4646

4747
When you need to keep track of how many times you already looped, you can use the `.enumerate()` function.
4848

49-
#### On ranges:
49+
## On ranges:
5050

5151
```rust
5252
for (i,j) in (5..10).enumerate() {
5353
println!("i = {} and j = {}", i, j);
5454
}
5555
```
56+
5657
Outputs:
57-
```
58+
59+
```rust
5860
i = 0 and j = 5
5961
i = 1 and j = 6
6062
i = 2 and j = 7
6163
i = 3 and j = 8
6264
i = 4 and j = 9
6365
```
66+
6467
Don't forget to add the parentheses around the range.
6568

66-
#### On iterators:
69+
## On iterators:
70+
6771
```rust
6872
for (linenumber, line) in lines.enumerate() {
6973
println!("{}: {}", linenumber, line);
7074
}
7175
```
76+
7277
Outputs:
73-
```
78+
79+
```rust
7480
0: Content of line one
7581
1: Content of line two
7682
2: Content of line tree

0 commit comments

Comments
 (0)