diff options
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/indexed_vec.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index b3918f1e4bc..91234631499 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -15,6 +15,7 @@ use std::marker::PhantomData; use std::ops::{Index, IndexMut, Range}; use std::fmt; use std::vec; +use std::u32; use rustc_serialize as serialize; @@ -31,6 +32,11 @@ impl Idx for usize { fn index(self) -> usize { self } } +impl Idx for u32 { + fn new(idx: usize) -> Self { assert!(idx <= u32::MAX as usize); idx as u32 } + fn index(self) -> usize { self as usize } +} + #[derive(Clone)] pub struct IndexVec<I: Idx, T> { pub raw: Vec<T>, |
