Updated "while let" example.

This commit is contained in:
androm3da 2015-11-25 12:46:35 -06:00
parent 1b9a13e6ba
commit b1c5c26c68

View File

@ -58,7 +58,8 @@ if let Some(x) = option {
## `while let`
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:
loop over an iterator as long as a value matches a certain pattern. It turns
code like this:
```rust
# let option: Option<i32> = None;
@ -73,8 +74,9 @@ loop {
Into code like this:
```rust
# let option: Option<i32> = None;
while let Some(x) = option {
# let v: vec![1, 3, 5, 7, 9, ];
# let mut it: v.iter();
while let Some(x) = it.next() {
println!("{}", x);
}
```