// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // This makes use of a clever hack that brson came up with to // workaround our lack of traits and lack of macros. See core.{rc,rs} for // how this file is used. #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; use cmp::{Eq, Ord}; use iter::BaseIter; use iter; use kinds::Copy; use option::Option; use self::inst::{IMPL_T, EACH, SIZE_HINT}; impl IMPL_T: iter::BaseIter { pure fn each(&self, blk: fn(v: &A) -> bool) { EACH(self, blk) } pure fn size_hint(&self) -> Option { SIZE_HINT(self) } } impl IMPL_T: iter::ExtendedIter { pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } pure fn all(&self, blk: fn(&A) -> bool) -> bool { iter::all(self, blk) } pure fn any(&self, blk: fn(&A) -> bool) -> bool { iter::any(self, blk) } pure fn foldl(&self, b0: B, blk: fn(&B, &A) -> B) -> B { iter::foldl(self, move b0, blk) } pure fn position(&self, f: fn(&A) -> bool) -> Option { iter::position(self, f) } pure fn map_to_vec(&self, op: fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } pure fn flat_map_to_vec>(&self, op: fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } } impl IMPL_T: iter::EqIter { pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } pure fn count(&self, x: &A) -> uint { iter::count(self, x) } } impl IMPL_T: iter::CopyableIter { pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } pure fn find(&self, f: fn(&A) -> bool) -> Option { iter::find(self, f) } } impl IMPL_T: iter::CopyableOrderedIter { pure fn min(&self) -> A { iter::min(self) } pure fn max(&self) -> A { iter::max(self) } }