Advertisement
cwchen

[Rust] for loop with a flag

Aug 22nd, 2017
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.19 KB | None | 0 0
  1. fn main() {
  2.     let mut i = 1;
  3.     let mut flag = false;
  4.  
  5.     while !flag {
  6.         println!("{}", i);
  7.         i += 1;
  8.  
  9.         if i > 5 {
  10.             flag = true;
  11.         }
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement