diff --git a/src/file/env.rs b/src/file/env.rs index 5635b67..2cdc30d 100644 --- a/src/file/env.rs +++ b/src/file/env.rs @@ -1,9 +1,11 @@ +use crate::prelude::*; + use std::fs::{File, OpenOptions}; use std::io::Write; -pub type FileOpenFn = Box std::io::Result>; +pub type FileOpenFn = Box Result>; -pub type FileAppendLineFn = Box std::io::Result<()>>; +pub type FileAppendLineFn = Box Result<()>>; pub struct FileEnv { pub open: FileOpenFn, @@ -12,7 +14,7 @@ pub struct FileEnv { impl Default for FileEnv { fn default() -> Self { Self { - open: Box::new(|path| File::open(path)), + open: Box::new(|path| Ok(File::open(path)?)), append_line: Box::new(|file_name, line| { let mut file = OpenOptions::new() .write(true) diff --git a/src/file/mod.rs b/src/file/mod.rs index 3a55a73..6b6c968 100644 --- a/src/file/mod.rs +++ b/src/file/mod.rs @@ -1,4 +1,6 @@ mod env; pub mod read; +pub use env::FileAppendLineFn; pub use env::FileEnv; +pub use env::FileOpenFn;