Corrections to the while-let example per review.

This commit is contained in:
ebadf 2015-11-25 20:05:45 -06:00
parent b1c5c26c68
commit 465a5cb194

View File

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