Skip to content

Commit f032b61

Browse files
committed
Import some core Items
1 parent 9ce0fdd commit f032b61

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/seq/index.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// except according to those terms.
88

99
//! Low-level API for sampling indices
10+
use core::{cmp::Ordering, hash::Hash, ops::AddAssign};
1011

1112
#[cfg(feature = "alloc")]
1213
use core::slice;
@@ -337,23 +338,27 @@ where
337338
index: N,
338339
key: f64,
339340
}
341+
340342
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> {
342344
Some(self.cmp(other))
343345
}
344346
}
347+
345348
impl<N> Ord for Element<N> {
346-
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
349+
fn cmp(&self, other: &Self) -> Ordering {
347350
// partial_cmp will always produce a value,
348351
// because we check that the weights are not nan
349352
self.key.partial_cmp(&other.key).unwrap()
350353
}
351354
}
355+
352356
impl<N> PartialEq for Element<N> {
353357
fn eq(&self, other: &Self) -> bool {
354358
self.key == other.key
355359
}
356360
}
361+
357362
impl<N> Eq for Element<N> {}
358363

359364
let mut candidates = Vec::with_capacity(length.as_usize());
@@ -442,13 +447,12 @@ where
442447
IndexVec::from(indices)
443448
}
444449

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 {
448451
fn zero() -> Self;
449452
fn one() -> Self;
450453
fn as_usize(self) -> usize;
451454
}
455+
452456
impl UInt for u32 {
453457
#[inline]
454458
fn zero() -> Self {
@@ -465,6 +469,7 @@ impl UInt for u32 {
465469
self as usize
466470
}
467471
}
472+
468473
impl UInt for usize {
469474
#[inline]
470475
fn zero() -> Self {

0 commit comments

Comments
 (0)