Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add PartialEq to StarknetApiError #296

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use std::num::ParseIntError;
use serde_utils::InnerDeserializationError;

/// The error type returned by StarknetApi.
#[derive(thiserror::Error, Clone, Debug)]
// Note: if you need `Eq` see InnerDeserializationError's docstring.
#[derive(thiserror::Error, Clone, Debug, PartialEq)]
pub enum StarknetApiError {
/// Error in the inner deserialization of the node.
#[error(transparent)]
Expand Down
10 changes: 9 additions & 1 deletion src/serde_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ impl<const N: usize, const PREFIXED: bool> Serialize for BytesAsHex<N, PREFIXED>
}

/// The error type returned by the inner deserialization.
#[derive(thiserror::Error, Clone, Debug)]
// If you need `eq`, add `impl Eq fro InnerDeserializationError {}` and read warning below.
//
// For some reason `hex` (now unmaintained for > 3 years) didn't implement `Eq`, even though
// there's no reason not too, so we can't use `derive(Eq)` unfortunately.
// Note that adding the impl is risky, because if at some point `hex` decide to add non-Eq
// things to the error, then combined with the manual `impl Eq` this will create very nasty bugs.
// So, for prudence, we'll hold off on adding `Eq` until we have a good reason to.
// Existing (ignored) issue on this: https://github.com/KokaKiwi/rust-hex/issues/76.
#[derive(thiserror::Error, Clone, Debug, PartialEq)]
pub enum InnerDeserializationError {
/// Error parsing the hex string.
#[error(transparent)]
Expand Down
Loading