diff options
-rw-r--r-- | src/main.rs | 12 | ||||
-rw-r--r-- | src/multi_error.rs | 26 |
2 files changed, 37 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 792b45a..9117674 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,7 +41,17 @@ fn main() { match run() { Ok(_) => (), Err(e) => { - eprintln!("error: {}", e); + // format!("{}", e) + // .lines() + // .for_each(|l| eprintln!("error: {}", e)); + // eprintln!(); + + // let errors = *e; + // errors.for_each(|e| eprintln!("error: {}", e)); + + e + .into_iter() + .for_each(|e| eprintln!("error: {:#}", e)); process::exit(exitcode::SOFTWARE); }, diff --git a/src/multi_error.rs b/src/multi_error.rs index 6163f40..d3fdba5 100644 --- a/src/multi_error.rs +++ b/src/multi_error.rs @@ -17,6 +17,7 @@ use std::fmt; +// use std::ops::Deref; /// Wraps a list of errors. @@ -50,3 +51,28 @@ impl From<Vec<anyhow::Error>> for MultiError { MultiError { errors: errors } } } + +// impl Iterator for MultiError { +// type Item = anyhow::Error; +// +// fn next(&mut self) -> Option<Self::Item> { +// self.errors.next() +// } +// } + +impl IntoIterator for MultiError { + type Item = anyhow::Error; + type IntoIter = std::vec::IntoIter<Self::Item>; + + fn into_iter(self) -> Self::IntoIter { + self.errors.into_iter() + } +} + +// impl Deref for MultiError { +// type Target = [anyhow::Error]; +// +// fn deref(&self) -> &Self::Target { +// &self.errors +// } +// } |