News for hackers. Stuff that matters.
Re:Rust: Enums to Wrap Multiple Errors by Macha on Friday October 08, 2021 @11:31AM (#28800374)
For reducing the code to implement this pattern, `thiserror` is nice. `derive_more` also has similar functionality, and I tend to use that more personally because I use its other derives, and while thiserror has a slightly nicer API (derive_more will assume a unit struct's field is it's source, which is wrong more often than not in my codebase, since I avoid overdoing nested error enums), it's not worth adding another dep to do what the dep I already have can do: https://jeltef.github.io/derive_more/derive_more/error.html
Re:Rust: Enums to Wrap Multiple Errors by stormbrew on Friday October 08, 2021 @12:21PM (#28801029)
huh that's cool. If it also had a "better derive(Default)" as well I'd probably end up using this in almost everything I write tbh.
Re:Rust: Enums to Wrap Multiple Errors by onei on Friday October 08, 2021 @02:15PM (#28802318)
The downside to derive_more from what I can tell is that it impacts compile times fairly noticeably compared to the equivalent handwritten code. YMMV, but I've seen it removed from some crates for that specific reason.