rm CopyableNonstrictIter

copies can just be done explicitly: `xs.transform(|x|x.clone())`
This commit is contained in:
Daniel Micay 2013-06-12 23:09:56 -04:00
parent d68be89e69
commit 824a6277af
3 changed files with 1 additions and 53 deletions

View file

@ -59,13 +59,6 @@ pub trait CopyableOrderedIter<A:Copy + Ord> {
fn max(&self) -> A;
}
pub trait CopyableNonstrictIter<A:Copy> {
// Like "each", but copies out the value. If the receiver is mutated while
// iterating over it, the semantics must not be memory-unsafe but are
// otherwise undefined.
fn each_val(&const self, f: &fn(A) -> bool) -> bool;
}
// A trait for sequences that can be built by imperatively pushing elements
// onto them.
pub trait Buildable<A> {

View file

@ -47,7 +47,7 @@ pub use char::Char;
pub use container::{Container, Mutable, Map, Set};
pub use hash::Hash;
pub use old_iter::{BaseIter, ReverseIter, ExtendedIter, EqIter};
pub use old_iter::{CopyableIter, CopyableOrderedIter, CopyableNonstrictIter};
pub use old_iter::{CopyableIter, CopyableOrderedIter};
pub use iter::{Times, FromIter};
pub use iterator::{Iterator, IteratorUtil};
pub use num::{Num, NumCast};

View file

@ -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);
}
}