rm CopyableNonstrictIter
copies can just be done explicitly: `xs.transform(|x|x.clone())`
This commit is contained in:
parent
d68be89e69
commit
824a6277af
3 changed files with 1 additions and 53 deletions
|
@ -2630,41 +2630,6 @@ impl<A:Copy + Ord> old_iter::CopyableOrderedIter<A> for @[A] {
|
|||
fn max(&self) -> A { old_iter::max(self) }
|
||||
}
|
||||
|
||||
impl<'self,A:Copy> old_iter::CopyableNonstrictIter<A> for &'self [A] {
|
||||
fn each_val(&const self, f: &fn(A) -> bool) -> bool {
|
||||
let mut i = 0;
|
||||
while i < self.len() {
|
||||
if !f(copy self[i]) { return false; }
|
||||
i += 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#4148): This should be redundant
|
||||
impl<A:Copy> old_iter::CopyableNonstrictIter<A> for ~[A] {
|
||||
fn each_val(&const self, f: &fn(A) -> bool) -> bool {
|
||||
let mut i = 0;
|
||||
while i < uniq_len(self) {
|
||||
if !f(copy self[i]) { return false; }
|
||||
i += 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#4148): This should be redundant
|
||||
impl<A:Copy> old_iter::CopyableNonstrictIter<A> for @[A] {
|
||||
fn each_val(&const self, f: &fn(A) -> bool) -> bool {
|
||||
let mut i = 0;
|
||||
while i < self.len() {
|
||||
if !f(copy self[i]) { return false; }
|
||||
i += 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:Clone> Clone for ~[A] {
|
||||
#[inline]
|
||||
fn clone(&self) -> ~[A] {
|
||||
|
@ -4326,14 +4291,4 @@ mod tests {
|
|||
}
|
||||
assert_eq!(v, ~[~[1,2,3],~[1,3,2],~[2,1,3],~[2,3,1],~[3,1,2],~[3,2,1]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_each_val() {
|
||||
use old_iter::CopyableNonstrictIter;
|
||||
let mut i = 0;
|
||||
for [1, 2, 3].each_val |v| {
|
||||
i += v;
|
||||
}
|
||||
assert_eq!(i, 6);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue