~irimi1/learning-rust

ref: c5ee2198d69c1c05d641b957c325bada6e7c8a5b learning-rust/projects/loops/src/main.rs -rw-r--r-- 234 bytes
c5ee2198Manuel Groß minigrep: Make use of the search function 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
fn main() {
    let mut counter = 0;

    let result = loop {
        counter += 1;

        println!("Counter: {}", counter);

        if counter == 10 {
            break counter * 2;
        }
    };

    assert_eq!(result, 20);
}