i5-add-tests (part 4) #10

Merged
kemitix merged 39 commits from i5-add-tests into main 2023-08-05 06:50:01 +01:00
2 changed files with 7 additions and 3 deletions
Showing only changes of commit fede0eebf1 - Show all commits

View file

@ -1,9 +1,11 @@
use crate::prelude::*;
use std::fs::{File, OpenOptions};
use std::io::Write;
pub type FileOpenFn = Box<dyn Fn(&str) -> std::io::Result<File>>;
pub type FileOpenFn = Box<dyn Fn(&str) -> Result<File>>;
pub type FileAppendLineFn = Box<dyn Fn(&str, &str) -> std::io::Result<()>>;
pub type FileAppendLineFn = Box<dyn Fn(&str, &str) -> 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)

View file

@ -1,4 +1,6 @@
mod env;
pub mod read;
pub use env::FileAppendLineFn;
pub use env::FileEnv;
pub use env::FileOpenFn;