jsonstein@masto.deoan.org ("Jeff Sonstein") wrote:
playing around with handling file open/create issues... I think I like this style a bit better than the example in the book
----- snip -----
fn file_test4() {
let greeting_file4 = match File::open("hello4.txt") {
Ok(file) => file,
Err(error) => match error.kind() {
ErrorKind::NotFound => match File::create("hello4.txt") {
Ok(fc) => fc,
Err(e) => panic!("Problem creating file: {:?}", e),
},
other_error => {
panic!("Problem opening the file: {:?}", other_error);
}
},
};
}
----- snip -----but maybe I am missing something I'll bump into later...