Programming-Idioms

History of Idiom 42 > diff from v6 to v7

Edit summary for version 7 :

Version 6

2015-08-20, 20:49:22

Version 7

2015-08-20, 20:49:35

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