strengthen `Idx` to require `Ord + Hash`
You should always be able to know that any `T` where `T: Idx` can be used in a `BTreeMap` and a `FxHashMap`.
This commit is contained in:
parent
90c90ba542
commit
dab206f8b5
|
@ -14,6 +14,7 @@ use std::slice;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ops::{Index, IndexMut, Range, RangeBounds};
|
use std::ops::{Index, IndexMut, Range, RangeBounds};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::hash::Hash;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
use std::u32;
|
use std::u32;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ use rustc_serialize as serialize;
|
||||||
/// Represents some newtyped `usize` wrapper.
|
/// Represents some newtyped `usize` wrapper.
|
||||||
///
|
///
|
||||||
/// (purpose: avoid mixing indexes for different bitvector domains.)
|
/// (purpose: avoid mixing indexes for different bitvector domains.)
|
||||||
pub trait Idx: Copy + 'static + Eq + Debug {
|
pub trait Idx: Copy + 'static + Ord + Debug + Hash {
|
||||||
fn new(idx: usize) -> Self;
|
fn new(idx: usize) -> Self;
|
||||||
fn index(self) -> usize;
|
fn index(self) -> usize;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue