21
21
22
22
use std:: cmp:: Ordering ;
23
23
use std:: fmt:: { self , Display , Formatter } ;
24
+ use std:: hash:: { Hash , Hasher } ;
24
25
use std:: io;
25
26
26
27
use crate :: { ReadStruct , VariantName , WriteStruct , STRICT_TYPES_LIB } ;
@@ -82,7 +83,7 @@ impl Display for Sizing {
82
83
}
83
84
}
84
85
85
- #[ derive( Clone , Eq , Hash , Debug ) ]
86
+ #[ derive( Clone , Eq , Debug ) ]
86
87
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) , serde( crate = "serde_crate" ) ) ]
87
88
pub struct Variant {
88
89
pub name : VariantName ,
@@ -108,15 +109,20 @@ impl Variant {
108
109
}
109
110
110
111
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 }
114
113
}
115
114
116
115
impl PartialOrd for Variant {
117
116
fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > { Some ( self . cmp ( other) ) }
118
117
}
119
118
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
+
120
126
impl Ord for Variant {
121
127
fn cmp ( & self , other : & Self ) -> Ordering {
122
128
if self == other {
0 commit comments