7
7
// except according to those terms.
8
8
9
9
//! Low-level API for sampling indices
10
+ use core:: { cmp:: Ordering , hash:: Hash , ops:: AddAssign } ;
10
11
11
12
#[ cfg( feature = "alloc" ) ]
12
13
use core:: slice;
@@ -337,23 +338,27 @@ where
337
338
index : N ,
338
339
key : f64 ,
339
340
}
341
+
340
342
impl < N > PartialOrd for Element < N > {
341
- fn partial_cmp ( & self , other : & Self ) -> Option < core :: cmp :: Ordering > {
343
+ fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
342
344
Some ( self . cmp ( other) )
343
345
}
344
346
}
347
+
345
348
impl < N > Ord for Element < N > {
346
- fn cmp ( & self , other : & Self ) -> core :: cmp :: Ordering {
349
+ fn cmp ( & self , other : & Self ) -> Ordering {
347
350
// partial_cmp will always produce a value,
348
351
// because we check that the weights are not nan
349
352
self . key . partial_cmp ( & other. key ) . unwrap ( )
350
353
}
351
354
}
355
+
352
356
impl < N > PartialEq for Element < N > {
353
357
fn eq ( & self , other : & Self ) -> bool {
354
358
self . key == other. key
355
359
}
356
360
}
361
+
357
362
impl < N > Eq for Element < N > { }
358
363
359
364
let mut candidates = Vec :: with_capacity ( length. as_usize ( ) ) ;
@@ -442,13 +447,12 @@ where
442
447
IndexVec :: from ( indices)
443
448
}
444
449
445
- trait UInt :
446
- Copy + PartialOrd + Ord + PartialEq + Eq + SampleUniform + core:: hash:: Hash + core:: ops:: AddAssign
447
- {
450
+ trait UInt : Copy + PartialOrd + Ord + PartialEq + Eq + SampleUniform + Hash + AddAssign {
448
451
fn zero ( ) -> Self ;
449
452
fn one ( ) -> Self ;
450
453
fn as_usize ( self ) -> usize ;
451
454
}
455
+
452
456
impl UInt for u32 {
453
457
#[ inline]
454
458
fn zero ( ) -> Self {
@@ -465,6 +469,7 @@ impl UInt for u32 {
465
469
self as usize
466
470
}
467
471
}
472
+
468
473
impl UInt for usize {
469
474
#[ inline]
470
475
fn zero ( ) -> Self {
0 commit comments