Skip to content

Commit

Permalink
Derive Eq for types that already derive PartialEq
Browse files Browse the repository at this point in the history
  • Loading branch information
ramosbugs committed Feb 29, 2024
1 parent 3a801c9 commit 898ead2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ new_type![
///
/// OpenID Connect Core claim name.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
CoreClaimName(String)
];
impl ClaimName for CoreClaimName {}
Expand Down Expand Up @@ -557,7 +557,7 @@ new_type![
///
/// OpenID Connect Core gender claim.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
CoreGenderClaim(String)
];
impl GenderClaim for CoreGenderClaim {}
Expand Down
4 changes: 2 additions & 2 deletions src/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use std::ops::Deref;
use std::str;

new_type![
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
JsonWebTokenContentType(String)
];

new_type![
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
JsonWebTokenType(String)
];

Expand Down
4 changes: 2 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ macro_rules! new_type {
}
) => {
$(#[$attr])*
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct $name(
$(#[$type_attr])*
$type
Expand Down Expand Up @@ -155,7 +155,7 @@ macro_rules! new_type {
}
) => {
$(#[$attr])*
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct $name(
$(#[$type_attr])*
$type
Expand Down
60 changes: 30 additions & 30 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ new_type![
/// Set of authentication methods or procedures that are considered to be equivalent to each
/// other in a particular context.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
AuthenticationContextClass(String)
];
impl AsRef<str> for AuthenticationContextClass {
Expand All @@ -427,15 +427,15 @@ new_type![
///
/// Defining specific AMR identifiers is beyond the scope of the OpenID Connect Core spec.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
AuthenticationMethodReference(String)
];

new_type![
///
/// Access token hash.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
AccessTokenHash(String)
impl {
///
Expand Down Expand Up @@ -464,47 +464,47 @@ new_type![
///
/// Country portion of address.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
AddressCountry(String)
];

new_type![
///
/// Locality portion of address.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
AddressLocality(String)
];

new_type![
///
/// Postal code portion of address.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
AddressPostalCode(String)
];

new_type![
///
/// Region portion of address.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
AddressRegion(String)
];

new_type![
///
/// Audience claim value.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
Audience(String)
];

new_type![
///
/// Authorization code hash.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
AuthorizationCodeHash(String)
impl {
///
Expand All @@ -531,7 +531,7 @@ new_type![
];

new_type![
#[derive(Deserialize, Eq, Hash, Serialize)]
#[derive(Deserialize, Hash, Serialize)]
pub(crate) Base64UrlEncodedBytes(
#[serde(with = "serde_base64url_byte_array")]
Vec<u8>
Expand All @@ -542,7 +542,7 @@ new_type![
///
/// OpenID Connect client name.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
ClientName(String)
];

Expand All @@ -564,7 +564,7 @@ new_type![
///
/// Client contact e-mail address.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
ClientContactEmail(String)
];

Expand All @@ -586,79 +586,79 @@ new_type![
/// providing just year can result in varying month and day, so the implementers need to take
/// this factor into account to correctly process the dates.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserBirthday(String)
];

new_type![
///
/// End user's e-mail address.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserEmail(String)
];

new_type![
///
/// End user's family name.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserFamilyName(String)
];

new_type![
///
/// End user's given name.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserGivenName(String)
];

new_type![
///
/// End user's middle name.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserMiddleName(String)
];

new_type![
///
/// End user's name.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserName(String)
];

new_type![
///
/// End user's nickname.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserNickname(String)
];

new_type![
///
/// End user's phone number.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserPhoneNumber(String)
];

new_type![
///
/// URL of end user's profile picture.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserPictureUrl(String)
];

new_type![
///
/// URL of end user's profile page.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserProfileUrl(String)
];

Expand All @@ -667,23 +667,23 @@ new_type![
/// End user's time zone as a string from the
/// [time zone database](https://www.iana.org/time-zones).
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserTimezone(String)
];

new_type![
///
/// URL of end user's website.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserWebsiteUrl(String)
];

new_type![
///
/// End user's username.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
EndUserUsername(String)
];

Expand All @@ -695,7 +695,7 @@ new_type![
/// either as a carriage return/line feed pair (`"\r\n"`) or as a single line feed character
/// (`"\n"`).
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
FormattedAddress(String)
];

Expand Down Expand Up @@ -733,7 +733,7 @@ new_type![
///
/// ID of a JSON Web Key.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
JsonWebKeyId(String)
];

Expand Down Expand Up @@ -951,7 +951,7 @@ new_type![
///
/// Language tag adhering to RFC 5646 (e.g., `fr` or `fr-CA`).
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
LanguageTag(String)
];
impl AsRef<str> for LanguageTag {
Expand Down Expand Up @@ -1170,7 +1170,7 @@ new_type![
/// separated by newlines. Newlines can be represented either as a carriage return/line feed
/// pair (`\r\n`) or as a single line feed character (`\n`).
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
StreetAddress(String)
];

Expand All @@ -1179,7 +1179,7 @@ new_type![
/// Locally unique and never reassigned identifier within the Issuer for the End-User, which is
/// intended to be consumed by the client application.
///
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
#[derive(Deserialize, Hash, Ord, PartialOrd, Serialize)]
SubjectIdentifier(String)
];

Expand Down

0 comments on commit 898ead2

Please sign in to comment.