Remaining flow control in RBE
This commit is contained in:
13
rustbyexample/flow_control.d/while_let.rs
Normal file
13
rustbyexample/flow_control.d/while_let.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
fn main() {
|
||||
let mut optional = Some(0);
|
||||
|
||||
while let Some(i) = optional {
|
||||
if i > 9 {
|
||||
println!("Greater than 9, quit!");
|
||||
optional = None;
|
||||
} else {
|
||||
println!("`i` is `{:?}`. Try again.", i);
|
||||
optional = Some(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user