rust-email icon indicating copy to clipboard operation
rust-email copied to clipboard

Add useful traits to errors

Open tredoe opened this issue 9 years ago • 4 comments

Please add #[derive(PartialEq, Eq, Copy, Clone, Debug)] so the error could be compared in tests of other libraries/apps that use your library, or be copied. Thanks in advance!

https://github.com/niax/rust-email/blob/master/src/results.rs#L4

tredoe avatar Nov 16 '16 09:11 tredoe

Not going to implement Copy, but fine with the rest

untitaker avatar Nov 16 '16 12:11 untitaker

https://www.reddit.com/r/rust/comments/5d8frm/traits_derived_in_errors/

tredoe avatar Nov 16 '16 12:11 tredoe

That post is simply wrong. The error contains a string and can't implement Copy (only Clone)

untitaker avatar Nov 16 '16 12:11 untitaker

Well, in general it's a good idea to encode the error reason as much into an enum as possible (and not a string), so in the ideal case Copy can be derived. But not for the general case.

untitaker avatar Nov 16 '16 12:11 untitaker