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:
Niko Matsakis 2018-07-02 10:55:44 -04:00
parent 90c90ba542
commit dab206f8b5
1 changed files with 2 additions and 1 deletions

View File

@ -14,6 +14,7 @@ use std::slice;
use std::marker::PhantomData;
use std::ops::{Index, IndexMut, Range, RangeBounds};
use std::fmt;
use std::hash::Hash;
use std::vec;
use std::u32;
@ -22,7 +23,7 @@ use rustc_serialize as serialize;
/// Represents some newtyped `usize` wrapper.
///
/// (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 index(self) -> usize;
}