Skip to content

Commit

Permalink
feat: impl PartielEq for Error
Browse files Browse the repository at this point in the history
  • Loading branch information
ihrwein committed Nov 19, 2021
1 parent 725b4a0 commit 113a0c5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,27 @@ impl<E> From<E> for Error<E> {
}
}
}

impl<E> PartialEq for Error<E>
where
E: PartialEq,
{
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Error::Permanent(ref self_err), Error::Permanent(ref other_err)) => {
self_err == other_err
}
(
Error::Transient {
err: self_err,
retry_after: self_retry_after,
},
Error::Transient {
err: other_err,
retry_after: other_retry_after,
},
) => self_err == other_err && self_retry_after == other_retry_after,
_ => false,
}
}
}

0 comments on commit 113a0c5

Please sign in to comment.