]> git.lizzy.rs Git - rust.git/commitdiff
strengthen `Idx` to require `Ord + Hash`
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 2 Jul 2018 14:55:44 +0000 (10:55 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 12 Jul 2018 04:38:40 +0000 (00:38 -0400)
You should always be able to know that any `T` where `T: Idx`
can be used in a `BTreeMap` and a `FxHashMap`.

src/librustc_data_structures/indexed_vec.rs

index ad3710e9536f1af1c401821992c3fec0e23476c0..26de2191090e3a8d70dc9dd2b789fa56aadc3b0e 100644 (file)
@@ -14,6 +14,7 @@
 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 @@
 /// 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;
 }