use std::{fs::File, io::ErrorKind}; fn main(){ let f = File::open("secret.pem"); let f = match f { Ok(_) => (), Err(ref error) if error.kind() == ErrorKind::NotFound => println!("Not found"), Err(error) => { panic!("There was a problem opening the file: {:?}", error); } }; println!("OK"); }
何もしない場合は、Ok(_) => () と書いた。