Advertisement
cwchen

[Rust] for loop with loop label

Aug 22nd, 2017
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.29 KB | None | 0 0
  1. fn main() {
  2.     'outer: for x in 0..10 {
  3.        'inner: for y in 0..10 {
  4.             if x % 2 == 0 { continue 'outer; } // continues the loop over x
  5.            if y % 2 == 0 { continue 'inner; } // continues the loop over y
  6.             println!("x: {}, y: {}", x, y);
  7.         }
  8.     }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement