aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorTeddy Wing2021-06-13 14:53:47 +0200
committerTeddy Wing2021-06-13 14:53:47 +0200
commitbdb52392162500ed1b55e68527668c3b41386c2a (patch)
treeff721db6ba7036441351b8dc7da4424e202854ea /src/main.rs
parent8c247b5c2881e91a54622eb90dad8ca777db592e (diff)
downloadreflectub-bdb52392162500ed1b55e68527668c3b41386c2a.tar.bz2
main(): Print "error: " in front of each error line
Prefix each error line with the text "error: " to make it clear that's what it is, and that it's separate from errors printed on other lines. Worked out how to set up an `Iterator` for `MultiError` based on a comment by 'chris-morgan' (https://old.reddit.com/user/chris-morgan) on Reddit /r/rust: > 1. Implement your own iterator type which wraps existing iterator > types (std::slice::Iter, and std::vec::IntoIter if you want a > consuming iterator). > Advantages: most flexible, ensures API stability if you > need to change internal details. > Disadvantages: a lot more effort, if you want to do it properly > (which involves implementing about ten traits on your iterator > wrapper type); and if slices or their iterators add something new, > you don’t get it unless you implement a wrapper yourself. > > 2. Have your iter() functions and IntoIterator implementations use the > standard iterator types directly. > Advantages: easier, gets you all the other trait implementations on > std::slice::Iter for free—AsRef, Clone, FusedIterator, > ExactSizeIterator, Debug, Send, DoubleEndedIterator, TrustedLen, > Sync). > Disadvantages: if you need to restructure things so that this is no > longer an option (e.g. store things in a different type of vector > and thus need to map it before presenting it to the user) it’s a > breaking change. > > 3. Implement Deref<Target = [(K, V)]> and just treat your Bucket<K, V> > as a &[(K, V)]. (Read-only; implement DerefMut if you want to allow > mutations of values.) > Advantages: easy, and lets you simply treat the whole thing as a > slice (this is what Vec<T> does). > Disadvantages: there really aren’t any, if it matches your purpose. > (If not, it’s useless.) (https://old.reddit.com/r/rust/comments/7a0slp/questionimplementing_iterator_for_a_struct_with_a/)
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs12
1 files changed, 11 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);
},