Programming-Idioms

History of Idiom 43 > diff from v37 to v38

Edit summary for version 38 :
[Rust] Fix indents

Version 37

2017-10-21, 11:24:45

Version 38

2018-12-17, 19:45:20

Idiom #43 Break outer loop

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

Illustration

Idiom #43 Break outer loop

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

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