Programming-Idioms

History of Idiom 42 > diff from v5 to v6

Edit summary for version 6 :

Version 5

2015-08-20, 20:48:29

Version 6

2015-08-20, 20:49:22

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Code
'outer: for va in &a {
    for vb in &b {
        if va == vb {
            continue 'outer;
        }
    }
    println!("{}", va);
}
Code
'outer: for va in &a {
    for vb in &b {
        if va == vb {
            continue 'outer;
        }
    }
    println!("{}", va);
}
Comments bubble
'outer is a label used to refer to the outer loop. Labels in Rust start with a '.
Comments bubble
_'outer is a label used to refer to the outer loop. Labels in Rust start with a _'.
Demo URL
https://play.rust-lang.org/?gist=f02f06e7c244558e542d&version=stable
Demo URL
https://play.rust-lang.org/?gist=f02f06e7c244558e542d&version=stable