summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcc <cc@localhost>2025-08-20 19:00:55 -0700
committercc <cc@localhost>2025-08-20 19:05:09 -0700
commit98f1bf9c4345eadcf2b15902f3a30d7c8483bb9e (patch)
tree35de43adb5e93b66a783548e0d210d1308c99a3d /src
parentb0ff49fdd4ae82af5cf89180078ea7314072c29f (diff)
Simplify Error Handling
Diffstat (limited to 'src')
-rw-r--r--src/binfile.rs10
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(())
}