At the very least, it would be great if serde_json::Error derived Clone. Eq and PartialEq would be nice bonuses. This would make the library more ergonomic and improve testability as it allows a direct comparison of expected errors. Clone would be nice if a serialization error needs to get passed to more than one thread across a channel.
Hmm, well, it looks like even the std library error types generally don't provide Clone. I'll just close this and go write newtype wrappers.
I'd like to request that this issue be re-opened. Without deriving PartialEq its impossible to test using asserrt_eq!. What's the best way to test code that uses serde_json internally?
@dtolnay I'd also like this to be reconsidered. In ruma-events, I currently have to .to_string() json errors because I want structs that indirectly contain them to implement Clone.
@dtolnay
+1 for the case. Lack of Clone implementation pushes developers to use .to_string() ending up with stringly-typed opaque errors.
Most helpful comment
@dtolnay
+1 for the case. Lack of
Cloneimplementation pushes developers to use.to_string()ending up with stringly-typed opaque errors.