parent
91e804409b
commit
7df3bf1860
@ -125,7 +125,8 @@ Don't forget to add the parentheses around the range.
|
|||||||
#### On iterators:
|
#### On iterators:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
# let lines = "hello\nworld".lines();
|
let lines = "hello\nworld".lines();
|
||||||
|
|
||||||
for (linenumber, line) in lines.enumerate() {
|
for (linenumber, line) in lines.enumerate() {
|
||||||
println!("{}: {}", linenumber, line);
|
println!("{}: {}", linenumber, line);
|
||||||
}
|
}
|
||||||
@ -134,10 +135,8 @@ for (linenumber, line) in lines.enumerate() {
|
|||||||
Outputs:
|
Outputs:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
0: Content of line one
|
0: hello
|
||||||
1: Content of line two
|
1: world
|
||||||
2: Content of line three
|
|
||||||
3: Content of line four
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ending iteration early
|
## Ending iteration early
|
||||||
|
Loading…
x
Reference in New Issue
Block a user