vec: remove eachi

replaced by the `enumerate` method from std::iterator
This commit is contained in:
Daniel Micay
2013-06-17 16:37:11 -04:00
parent 62dc4e0d4c
commit cbad1da3db
6 changed files with 12 additions and 53 deletions

View File

@@ -1427,21 +1427,6 @@ pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool {
return !broke;
}
/**
* Iterates over a vector's elements and indices
*
* Return true to continue, false to break.
*/
#[inline]
pub fn eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) -> bool {
let mut i = 0;
for each(v) |p| {
if !f(i, p) { return false; }
i += 1;
}
return true;
}
/**
* Iterate over all permutations of vector `v`.
*
@@ -3259,17 +3244,6 @@ mod tests {
assert_eq!(i, 6);
}
#[test]
fn test_eachi() {
let mut i = 0;
for eachi([1, 2, 3]) |j, v| {
if i == 0 { assert!(*v == 1); }
assert_eq!(j + 1u, *v as uint);
i += *v;
}
assert_eq!(i, 6);
}
#[test]
fn test_each_ret_len0() {
let a0 : [int, .. 0] = [];
@@ -4111,21 +4085,6 @@ mod tests {
};
}
#[test]
#[ignore(windows)]
#[should_fail]
fn test_eachi_fail() {
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
let mut i = 0;
do eachi(v) |_i, _elt| {
if i == 2 {
fail!()
}
i += 0;
false
};
}
#[test]
#[ignore(windows)]
#[should_fail]