From: Niko Matsakis Date: Mon, 2 Jul 2018 14:55:44 +0000 (-0400) Subject: strengthen `Idx` to require `Ord + Hash` X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=dab206f8b57bba507436e23e0e80a6d1ed80bfc4;p=rust.git 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`. --- diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index ad3710e9536..26de2191090 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -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; }