Shifted focus of while-let example per review.

This commit is contained in:
ebadf 2015-11-27 10:23:58 -06:00
parent 465a5cb194
commit 797a0bd1c1

View file

@ -61,10 +61,10 @@ In a similar fashion, `while let` can be used when you want to conditionally
loop as long as a value matches a certain pattern. It turns code like this:
```rust
# let option: Option<i32> = None;
let mut v = vec![1, 3, 5, 7, 11];
loop {
match option {
Some(x) => println!("{}", x),
match v.pop() {
Some(x) => println!("{}", x),
None => break,
}
}
@ -73,9 +73,8 @@ loop {
Into code like this:
```rust
let v: vec![1, 3, 5, 7, 11, ];
let mut iter: v.iter();
while let Some(x) = iter.next() {
let mut v = vec![1, 3, 5, 7, 11];
while let Some(x) = v.pop() {
println!("{}", x);
}
```