about summary refs log tree commit diff
path: root/src/librustc_data_structures/indexed_vec.rs
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2016-06-28 23:41:09 +0300
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2016-06-28 23:41:09 +0300
commitbff28ec46866bb2980d67a644e4e567b67ccb706 (patch)
treebf1248030e0f2c5fb5f82d63d4c609dcaf313b2b /src/librustc_data_structures/indexed_vec.rs
parentea0dc9297283daff6486807f43e190b4eb561412 (diff)
downloadrust-bff28ec46866bb2980d67a644e4e567b67ccb706.tar.gz
rust-bff28ec46866bb2980d67a644e4e567b67ccb706.zip
refactor rustc_metadata to use CamelCase names and IndexVec
Diffstat (limited to 'src/librustc_data_structures/indexed_vec.rs')
-rw-r--r--src/librustc_data_structures/indexed_vec.rs6
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>,