4
4
5
5
//! Kind
6
6
7
+ use core:: cmp:: Ordering ;
7
8
use core:: fmt;
8
9
use core:: hash:: { Hash , Hasher } ;
9
10
use core:: num:: ParseIntError ;
@@ -27,7 +28,7 @@ pub const EPHEMERAL_RANGE: Range<u64> = 20_000..30_000;
27
28
pub const PARAMETERIZED_REPLACEABLE_RANGE : Range < u64 > = 30_000 ..40_000 ;
28
29
29
30
/// Event [`Kind`]
30
- #[ derive( Debug , Clone , Copy , Eq , PartialOrd , Ord ) ]
31
+ #[ derive( Debug , Clone , Copy ) ]
31
32
pub enum Kind {
32
33
/// Metadata (NIP01 and NIP05)
33
34
Metadata ,
@@ -135,6 +136,35 @@ pub enum Kind {
135
136
Custom ( u64 ) ,
136
137
}
137
138
139
+ impl PartialEq < Kind > for Kind {
140
+ fn eq ( & self , other : & Kind ) -> bool {
141
+ self . as_u64 ( ) == other. as_u64 ( )
142
+ }
143
+ }
144
+
145
+ impl Eq for Kind { }
146
+
147
+ impl PartialOrd for Kind {
148
+ fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
149
+ Some ( self . cmp ( other) )
150
+ }
151
+ }
152
+
153
+ impl Ord for Kind {
154
+ fn cmp ( & self , other : & Self ) -> Ordering {
155
+ self . as_u64 ( ) . cmp ( & other. as_u64 ( ) )
156
+ }
157
+ }
158
+
159
+ impl Hash for Kind {
160
+ fn hash < H > ( & self , state : & mut H )
161
+ where
162
+ H : Hasher ,
163
+ {
164
+ self . as_u64 ( ) . hash ( state) ;
165
+ }
166
+ }
167
+
138
168
impl Kind {
139
169
/// Get [`Kind`] as `u32`
140
170
pub fn as_u32 ( & self ) -> u32 {
@@ -329,21 +359,6 @@ impl FromStr for Kind {
329
359
}
330
360
}
331
361
332
- impl PartialEq < Kind > for Kind {
333
- fn eq ( & self , other : & Kind ) -> bool {
334
- self . as_u64 ( ) == other. as_u64 ( )
335
- }
336
- }
337
-
338
- impl Hash for Kind {
339
- fn hash < H > ( & self , state : & mut H )
340
- where
341
- H : Hasher ,
342
- {
343
- self . as_u64 ( ) . hash ( state) ;
344
- }
345
- }
346
-
347
362
impl Add < u64 > for Kind {
348
363
type Output = Self ;
349
364
fn add ( self , rhs : u64 ) -> Self :: Output {
0 commit comments