diff --git a/src/bin.rs b/src/bin.rs index bf6445c..35aa36b 100644 --- a/src/bin.rs +++ b/src/bin.rs @@ -108,7 +108,7 @@ fn print_t_test(t_test: &TTest, s1: &Summary, s2: &Summary) { println!("{l:>w$} = {v}", w = width, l = "DF", v = t_test.df); } -fn summarize_file(path: &str, lax_parsing: bool) -> Result> { +fn summarize_file(path: &str, lax_parsing: bool) -> Result> { let f = File::open(path).or_else(|e| { log::error(&format!("Could not open file: {:?}", path)); Err(e) @@ -120,7 +120,7 @@ fn summarize_file(path: &str, lax_parsing: bool) -> Result(reader: R, lax_parsing: bool) -> Result, Box> +fn read_data(reader: R, lax_parsing: bool) -> Result, Box> where R: BufRead { let mut data: Vec = vec![]; @@ -140,7 +140,7 @@ fn read_data(reader: R, lax_parsing: bool) -> Result, Box Result> { +fn summarize_stdin(lax_parsing: bool) -> Result> { let stdin = io::stdin(); let data = read_data(stdin.lock(), lax_parsing)?; diff --git a/src/error.rs b/src/error.rs index cb8a751..002f330 100644 --- a/src/error.rs +++ b/src/error.rs @@ -11,17 +11,17 @@ pub enum Error { impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - write!(f, "{}", std::error::Error::description(self)) + write!( + f, + "{}", + match *self { + Error::BadSample => "All sample data must be finite", + Error::Diverged => "Numeric evaluation diverged", + Error::EmptySample => "Sample data set cannot be empty", + Error::Undefined => "Function undefined for argument", + } + ) } } -impl std::error::Error for Error { - fn description(&self) -> &str { - match *self { - Error::BadSample => "All sample data must be finite", - Error::Diverged => "Numeric evaluation diverged", - Error::EmptySample => "Sample data set cannot be empty", - Error::Undefined => "Function undefined for argument", - } - } -} +impl std::error::Error for Error {} diff --git a/tests/support/kat.rs b/tests/support/kat.rs index 89ac66e..b92bbe6 100644 --- a/tests/support/kat.rs +++ b/tests/support/kat.rs @@ -157,10 +157,8 @@ macro_rules! assert_appx_eq { ($name:expr, $tolerance:expr, $known:expr, $actual:expr) => { let d = ($known - $actual).abs(); - let err = format!("{}: {} and {} differ by {} > {}", - $name, $known, $actual, d, $tolerance); - - assert!(d < $tolerance, err); + assert!(d < $tolerance, "{}: {} and {} differ by {} > {}", + $name, $known, $actual, d, $tolerance); }; }