Keats / jsonwebtoken

JWT lib in rust
MIT License
1.69k stars 269 forks source link

Implement Clone and Eq for error type #217

Closed qwandor closed 2 years ago

qwandor commented 2 years ago

It would be helpful if jsonwebtoken::error::Error implemented Clone and Eq.

Keats commented 2 years ago

I would take a PR for it on the next branch.

qwandor commented 2 years ago

I've sent a PR for Eq.

It turns out Clone is more difficult, because serde_json::Error doesn't implement Clone. I can see two ways around this:

  1. Convert the serde_json::Error to a String and just wrap that instead. This would lose the ability to convert back to the serde_json type or get whatever other information it has.
  2. Wrap it in an Arc. I'm inclined to go with this option.
qwandor commented 2 years ago

I've gone ahead and gone the Arc route, I think it's a reasonable workaround.