diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binfile.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/binfile.rs b/src/binfile.rs index 9b50a70..a43f568 100644 --- a/src/binfile.rs +++ b/src/binfile.rs @@ -1,14 +1,14 @@ -pub fn dump_u32_vec(file_name: &str, data: Vec<u32>) -> Result<(), String> { +use std::io::{Error,ErrorKind}; + +pub fn dump_u32_vec(file_name: &str, data: Vec<u32>) -> Result<(), Error> { use std::fs::File; use std::io::Write; if let Ok(mut file) = File::create(file_name) { for value in data { - if let Err(error) = file.write_all(&value.to_le_bytes()) { - return Err(error.to_string()); - } + file.write_all(&value.to_le_bytes())?; } } else { - return Err(String::from("Error creating file")); + return Err(Error::new(ErrorKind::Other, "Error creating file")); } Ok(()) } |