Skip to content

Commit f78c4c6

Browse files
committed
chore: fix clippy lint on manual Hash derive when Eq is derived
1 parent 521eb23 commit f78c4c6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

rust/src/util.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
use std::cmp::Ordering;
2323
use std::fmt::{self, Display, Formatter};
24+
use std::hash::{Hash, Hasher};
2425
use std::io;
2526

2627
use crate::{ReadStruct, VariantName, WriteStruct, STRICT_TYPES_LIB};
@@ -82,7 +83,7 @@ impl Display for Sizing {
8283
}
8384
}
8485

85-
#[derive(Clone, Eq, Hash, Debug)]
86+
#[derive(Clone, Eq, Debug)]
8687
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "serde_crate"))]
8788
pub struct Variant {
8889
pub name: VariantName,
@@ -108,15 +109,20 @@ impl Variant {
108109
}
109110

110111
impl PartialEq for Variant {
111-
fn eq(&self, other: &Self) -> bool {
112-
self.tag == other.tag || self.name == other.name
113-
}
112+
fn eq(&self, other: &Self) -> bool { self.tag == other.tag || self.name == other.name }
114113
}
115114

116115
impl PartialOrd for Variant {
117116
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
118117
}
119118

119+
impl Hash for Variant {
120+
fn hash<H: Hasher>(&self, state: &mut H) {
121+
self.tag.hash(state);
122+
self.name.hash(state);
123+
}
124+
}
125+
120126
impl Ord for Variant {
121127
fn cmp(&self, other: &Self) -> Ordering {
122128
if self == other {

0 commit comments

Comments
 (0)