From dab206f8b57bba507436e23e0e80a6d1ed80bfc4 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 2 Jul 2018 10:55:44 -0400 Subject: [PATCH] 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`. --- src/librustc_data_structures/indexed_vec.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- 2.44.0