Skip to content

Commit 0e286bb

Browse files
committed
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`.
1 parent bdcaa6e commit 0e286bb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/librustc_data_structures/indexed_vec.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::slice;
1414
use std::marker::PhantomData;
1515
use std::ops::{Index, IndexMut, Range, RangeBounds};
1616
use std::fmt;
17+
use std::hash::Hash;
1718
use std::vec;
1819
use std::u32;
1920

@@ -22,7 +23,7 @@ use rustc_serialize as serialize;
2223
/// Represents some newtyped `usize` wrapper.
2324
///
2425
/// (purpose: avoid mixing indexes for different bitvector domains.)
25-
pub trait Idx: Copy + 'static + Eq + Debug {
26+
pub trait Idx: Copy + 'static + Ord + Debug + Hash {
2627
fn new(idx: usize) -> Self;
2728
fn index(self) -> usize;
2829
}

0 commit comments

Comments
 (0)