fn read_or_create_or_panic_v2() {
    let f = File::open("hello.txt").unwrap_or_else(|error| {
        if error.kind() == ErrorKind::NotFound {
            File::create("hello.txt").unwrap_or_else(|error| {
                panic!("Problem creating the file: {:?}", error);
            })
        } else {
            panic!("Problem opening the file: {:?}", error);
        }
    });
}
// Logically equivalent to the verbose version above
Logically equivalent to the verbose version above
Logically equivalent to the verbose version above
fn read_or_create_or_panic_v2() {
    let f = File::open("hello.txt").unwrap_or_else(|error| {
        if error.kind() == ErrorKind::NotFound {
            File::create("hello.txt").unwrap_or_else(|error| {
                panic!("Problem creating the file: {:?}", error);
            })
        } else {
            panic!("Problem opening the file: {:?}", error);
        }
    });
}
fn read_or_create_or_panic_v2 ( ) { let f = File :: open ( " " ) . unwrap_or_else ( | error | { if error . kind ( ) == ErrorKind :: NotFound { File :: create ( " " ) . unwrap_or_else ( | error | { panic ! ( " " error ) ; } ) } else { panic ! ( " " error ) ; } } ) ; }
Logically equivalent to the verbose version above
Logically equivalent to the verbose version above