aboutsummaryrefslogtreecommitdiffstats
path: root/src/multi_error.rs
AgeCommit message (Collapse)Author
2021-06-13MultiError: Remove impl `Iterator` testsTeddy Wing
Remove the `Iterator` test implementations that didn't work out.
2021-06-13main(): Print "error: " in front of each error lineTeddy Wing
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/)
2021-06-13MultiError: Add struct documentationTeddy Wing
2021-06-13Move `MultiError` to its own fileTeddy Wing