about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2016-06-07 21:20:50 +0300
committerAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2016-06-09 14:55:19 +0300
commite3af9fa4906594ba22015e549cf8bfc3201dec1b (patch)
treea98c4a76863fbc9d190d00d73bb533200c9f73b4 /src/librustc_data_structures
parentbc1eb67721a842d62bec8e879aad339fd22fe3c6 (diff)
downloadrust-e3af9fa4906594ba22015e549cf8bfc3201dec1b.tar.gz
rust-e3af9fa4906594ba22015e549cf8bfc3201dec1b.zip
make the basic_blocks field private
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/indexed_vec.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs
index b7697211241..db054477f75 100644
--- a/src/librustc_data_structures/indexed_vec.rs
+++ b/src/librustc_data_structures/indexed_vec.rs
@@ -11,7 +11,7 @@
 use std::iter::{self, FromIterator};
 use std::slice;
 use std::marker::PhantomData;
-use std::ops::{Index, IndexMut};
+use std::ops::{Index, IndexMut, Range};
 use std::fmt;
 use std::vec;
 
@@ -116,6 +116,11 @@ impl<I: Idx, T> IndexVec<I, T> {
     }
 
     #[inline]
+    pub fn indices(&self) -> iter::Map<Range<usize>, IntoIdx<I>> {
+        (0..self.len()).map(IntoIdx { _marker: PhantomData })
+    }
+
+    #[inline]
     pub fn iter_mut(&mut self) -> slice::IterMut<T> {
         self.raw.iter_mut()
     }
@@ -207,3 +212,17 @@ impl<I: Idx, T> FnMut<((usize, T),)> for IntoIdx<I> {
         (I::new(n), t)
     }
 }
+
+impl<I: Idx> FnOnce<(usize,)> for IntoIdx<I> {
+    type Output = I;
+
+    extern "rust-call" fn call_once(self, (n,): (usize,)) -> Self::Output {
+        I::new(n)
+    }
+}
+
+impl<I: Idx> FnMut<(usize,)> for IntoIdx<I> {
+    extern "rust-call" fn call_mut(&mut self, (n,): (usize,)) -> Self::Output {
+        I::new(n)
+    }
+}