Skip to content

Commit 465a5cb

Browse files
committed
Corrections to the while-let example per review.
1 parent b1c5c26 commit 465a5cb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/doc/book/if-let.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ if let Some(x) = option {
5858
## `while let`
5959

6060
In a similar fashion, `while let` can be used when you want to conditionally
61-
loop over an iterator as long as a value matches a certain pattern. It turns
62-
code like this:
61+
loop as long as a value matches a certain pattern. It turns code like this:
6362

6463
```rust
6564
# let option: Option<i32> = None;
@@ -74,9 +73,9 @@ loop {
7473
Into code like this:
7574

7675
```rust
77-
# let v: vec![1, 3, 5, 7, 9, ];
78-
# let mut it: v.iter();
79-
while let Some(x) = it.next() {
76+
let v: vec![1, 3, 5, 7, 11, ];
77+
let mut iter: v.iter();
78+
while let Some(x) = iter.next() {
8079
println!("{}", x);
8180
}
8281
```

0 commit comments

Comments
 (0)