From e3af9fa4906594ba22015e549cf8bfc3201dec1b Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 7 Jun 2016 21:20:50 +0300 Subject: make the basic_blocks field private --- src/librustc_data_structures/indexed_vec.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/librustc_data_structures') 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; @@ -115,6 +115,11 @@ impl IndexVec { self.raw.iter().enumerate().map(IntoIdx { _marker: PhantomData }) } + #[inline] + pub fn indices(&self) -> iter::Map, IntoIdx> { + (0..self.len()).map(IntoIdx { _marker: PhantomData }) + } + #[inline] pub fn iter_mut(&mut self) -> slice::IterMut { self.raw.iter_mut() @@ -207,3 +212,17 @@ impl FnMut<((usize, T),)> for IntoIdx { (I::new(n), t) } } + +impl FnOnce<(usize,)> for IntoIdx { + type Output = I; + + extern "rust-call" fn call_once(self, (n,): (usize,)) -> Self::Output { + I::new(n) + } +} + +impl FnMut<(usize,)> for IntoIdx { + extern "rust-call" fn call_mut(&mut self, (n,): (usize,)) -> Self::Output { + I::new(n) + } +} -- cgit 1.4.1-3-g733a5