Skip to content

Commit 797a0bd

Browse files
committed
Shifted focus of while-let example per review.
1 parent 465a5cb commit 797a0bd

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/doc/book/if-let.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ In a similar fashion, `while let` can be used when you want to conditionally
6161
loop as long as a value matches a certain pattern. It turns code like this:
6262

6363
```rust
64-
# let option: Option<i32> = None;
64+
let mut v = vec![1, 3, 5, 7, 11];
6565
loop {
66-
match option {
67-
Some(x) => println!("{}", x),
66+
match v.pop() {
67+
Some(x) => println!("{}", x),
6868
None => break,
6969
}
7070
}
@@ -73,9 +73,8 @@ loop {
7373
Into code like this:
7474

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

0 commit comments

Comments
 (0)