Logo

Programming-Idioms

History of Idiom 42 > diff from v41 to v42

Edit summary for version 42 by programming-idioms.org:
[Rust] +DocURL for continue

Version 41

2021-02-24, 13:29:34

Version 42

2021-04-06, 12:23:56

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.

Variables
v,a,b
Variables
v,a,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 '.
Doc URL
https://doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions
Demo URL
https://play.rust-lang.org/?gist=f02f06e7c244558e542d&version=stable
Demo URL
https://play.rust-lang.org/?gist=f02f06e7c244558e542d&version=stable