From e2e39234cc5509fb461b8805eeb32c5ce538ee6e Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 23 Jun 2013 17:57:39 -0400 Subject: remove old_iter the `test/run-pass/class-trait-bounded-param.rs` test was xfailed and written in an ancient dialect of Rust so I've just removed it this also removes `to_vec` from DList because it's provided by `std::iter::to_vec` an Iterator implementation is added for OptVec but some transitional internal iterator methods are still left --- src/libsyntax/ext/pipes/pipec.rs | 4 +- src/libsyntax/opt_vec.rs | 117 +++++++++++++-------------------------- 2 files changed, 40 insertions(+), 81 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index a20528082ab..55ac9c5ec1c 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -375,7 +375,7 @@ impl gen_init for protocol { let mut params: OptVec = opt_vec::Empty; for (copy self.states).iter().advance |s| { for s.generics.ty_params.each |tp| { - match params.find(|tpp| tp.ident == tpp.ident) { + match params.iter().find_(|tpp| tp.ident == tpp.ident) { None => params.push(*tp), _ => () } @@ -393,7 +393,7 @@ impl gen_init for protocol { let mut params: OptVec = opt_vec::Empty; let fields = do (copy self.states).iter().transform |s| { for s.generics.ty_params.each |tp| { - match params.find(|tpp| tp.ident == tpp.ident) { + match params.iter().find_(|tpp| tp.ident == tpp.ident) { None => params.push(*tp), _ => () } diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index c537a3e8eba..8917b481dc7 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -17,9 +17,7 @@ */ use core::prelude::*; - -use core::old_iter; -use core::old_iter::BaseIter; +use core::vec::VecIterator; #[deriving(Encodable, Decodable)] pub enum OptVec { @@ -40,6 +38,13 @@ pub fn from(t: ~[T]) -> OptVec { } impl OptVec { + fn each(&self, blk: &fn(v: &T) -> bool) -> bool { + match *self { + Empty => true, + Vec(ref v) => v.iter().advance(blk) + } + } + fn push(&mut self, t: T) { match *self { Vec(ref mut v) => { @@ -78,6 +83,28 @@ impl OptVec { Vec(ref v) => v.len() } } + + #[inline] + fn iter<'r>(&'r self) -> OptVecIterator<'r, T> { + match *self { + Empty => OptVecIterator{iter: None}, + Vec(ref v) => OptVecIterator{iter: Some(v.iter())} + } + } + + #[inline] + fn map_to_vec(&self, op: &fn(&T) -> B) -> ~[B] { + self.iter().transform(op).collect() + } + + fn mapi_to_vec(&self, op: &fn(uint, &T) -> B) -> ~[B] { + let mut index = 0; + self.map_to_vec(|a| { + let i = index; + index += 1; + op(i, a) + }) + } } pub fn take_vec(v: OptVec) -> ~[T] { @@ -96,22 +123,6 @@ impl OptVec { } return Vec(v0); } - - fn push_all>(&mut self, from: &I) { - for from.each |e| { - self.push(copy *e); - } - } - - #[inline] - fn mapi_to_vec(&self, op: &fn(uint, &T) -> B) -> ~[B] { - let mut index = 0; - old_iter::map_to_vec(self, |a| { - let i = index; - index += 1; - op(i, a) - }) - } } impl Eq for OptVec { @@ -131,68 +142,16 @@ impl Eq for OptVec { } } -impl BaseIter for OptVec { - fn each(&self, blk: &fn(v: &A) -> bool) -> bool { - match *self { - Empty => true, - Vec(ref v) => v.iter().advance(blk) - } - } - - fn size_hint(&self) -> Option { - Some(self.len()) - } +pub struct OptVecIterator<'self, T> { + priv iter: Option> } -impl old_iter::ExtendedIter for OptVec { +impl<'self, T> Iterator<&'self T> for OptVecIterator<'self, T> { #[inline] - fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) -> bool { - old_iter::eachi(self, blk) - } - #[inline] - fn all(&self, blk: &fn(&A) -> bool) -> bool { - old_iter::all(self, blk) - } - #[inline] - fn any(&self, blk: &fn(&A) -> bool) -> bool { - old_iter::any(self, blk) - } - #[inline] - fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { - old_iter::foldl(self, b0, blk) - } - #[inline] - fn position(&self, f: &fn(&A) -> bool) -> Option { - old_iter::position(self, f) - } - #[inline] - fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { - old_iter::map_to_vec(self, op) - } - #[inline] - fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) - -> ~[B] { - old_iter::flat_map_to_vec(self, op) - } - -} - -impl old_iter::EqIter for OptVec { - #[inline] - fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) } - #[inline] - fn count(&self, x: &A) -> uint { old_iter::count(self, x) } -} - -impl old_iter::CopyableIter for OptVec { - #[inline] - fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { - old_iter::filter_to_vec(self, pred) - } - #[inline] - fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) } - #[inline] - fn find(&self, f: &fn(&A) -> bool) -> Option { - old_iter::find(self, f) + fn next(&mut self) -> Option<&'self T> { + match self.iter { + Some(ref mut x) => x.next(), + None => None + } } } -- cgit 1.4.1-3-g733a5