diff --git a/solutions/24_file_io/file_io1.rs b/solutions/24_file_io/file_io1.rs index 9012f54e..ece68a67 100644 --- a/solutions/24_file_io/file_io1.rs +++ b/solutions/24_file_io/file_io1.rs @@ -13,8 +13,8 @@ fn main() { assert_eq!("This is the file content.", contents); } Err(e) => { - eprintln!("Error reading file: {}", e); - assert!(false); + panic!("Error reading file."); + } } } diff --git a/solutions/24_file_io/file_io2.rs b/solutions/24_file_io/file_io2.rs index af7af411..ba6aff20 100644 --- a/solutions/24_file_io/file_io2.rs +++ b/solutions/24_file_io/file_io2.rs @@ -48,11 +48,11 @@ fn main() { fn create_required_files(){ let file_path = Path::new(TEST_FILE_NAME); - if file_path.exists() == false { + if !file_path.exists() { let text = "This is the first line of the text. This is the second line. And this is the third and the last line."; - fs::write(&file_path, text).unwrap(); + fs::write(file_path, text).unwrap(); println!("File created."); } diff --git a/solutions/24_file_io/file_io3.rs b/solutions/24_file_io/file_io3.rs index f4e95d12..1bc2a3e8 100644 --- a/solutions/24_file_io/file_io3.rs +++ b/solutions/24_file_io/file_io3.rs @@ -33,17 +33,17 @@ fn create_required_files(){ let dir_path = file_path.parent().unwrap(); - if dir_path.exists() == false { + if !dir_path.exists() { fs::create_dir(dir_path).unwrap(); println!("Created directory {:?}", dir_path); } - if file_path.exists() == false { + if !file_path.exists(){ let text = "This is the first line of the text. This is the second line. And this is the third and the last line."; - fs::write(&file_path, text).unwrap(); + fs::write(file_path, text).unwrap(); println!("File created."); }