Mastodon Feed: Post

Mastodon Feed

jsonstein@masto.deoan.org ("Jeff Sonstein") wrote:

I am curious if experienced Rust programmers find the first approach or the second more comfortable:

----- snip -----
fn file_test() {
let greeting_file_result1 = File::open("hello1.txt");
let greeting_file1 = match greeting_file_result1 {
Ok(file) => file,
Err(error) => panic!("Problem opening the file: {:?}", error),
};
//
// versus
//
let greeting_file2 = match File::open("hello2.txt") {
Ok(file) => file,
Err(error) => panic!("Problem opening the file: {:?}", error),
};
}
----- snip -----

thanks in advance for any comments on advantages of one over the other

#LearningRust