Programming-Idioms

History of Idiom 43 > diff from v54 to v55

Edit summary for version 55 :
[Rust] Avoid link shortener if possible

Version 54

2020-03-03, 19:58:45

Version 55

2020-03-20, 17:56:38

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
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=bb1304afbfb08a6b35d2873409d76fcb