Programming-Idioms

History of Idiom 43 > diff from v9 to v10

Edit summary for version 10 :

Version 9

2015-08-01, 17:39:47

Version 10

2015-08-18, 13:27:42

Idiom #43 Break outer loop

Look for a negative value v in 2D integer matrix m. Print it and stop searching.

Idiom #43 Break outer loop

Look for a negative value v in 2D integer matrix m. Print it and stop searching.

Code
'outer: for v in m {
        'inner: for i in v {
            if i < 0 {
                println!("Found {}", i);
                break 'outer;
            }
        }
    }
Comments bubble
Loop label syntax is similar to lifetimes.
Origin
http://stackoverflow.com/a/22906579/1254484
Demo URL
http://is.gd/Uw926A