Untitled Project
line_range.rs
Source file coverage
Path:
line_range.rs
Lines:
26
Non-empty lines:
23
Non-empty lines covered with requirements:
23 / 23 (100.0%)
Functions:
1
Functions covered by requirements:
1 / 1 (100.0%)
1
fn main() {
2
    // Make `optional` of type `Option<i32>`
3
    // @relation(RUST-LINE-RANGE, scope=line)
4
    let mut optional = Some(0);
5
 
6
    // This reads: "while `let` destructures `optional` into
7
    // `Some(i)`, evaluate the block (`{}`). Else `break`.
8
    // @relation(RUST-LINE-RANGE, scope=range_start)
9
    while let Some(i) = optional {
10
        if i > 9 {
11
            println!("Greater than 9, quit!");
12
            optional = None;
13
        } else {
14
            println!("`i` is `{:?}`. Try again.", i);
15
            optional = Some(i + 1);
16
        }
17
        // ^ Less rightward drift and doesn't require
18
        // explicitly handling the failing case.
19
    }
20
    // @relation(RUST-LINE-RANGE, scope=range_end)
21
 
22
    // ^ `if let` had additional optional `else`/`else if`
23
    // clauses. `while let` does not have these.
24
 
25
    // @relation(RUST-LINE-RANGE, scope=file)
26
}