From 824a6277af9e614767e0570ecc282065256ac32a Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Wed, 12 Jun 2013 23:09:56 -0400 Subject: [PATCH] rm CopyableNonstrictIter copies can just be done explicitly: `xs.transform(|x|x.clone())` --- src/libstd/old_iter.rs | 7 ------- src/libstd/prelude.rs | 2 +- src/libstd/vec.rs | 45 ------------------------------------------ 3 files changed, 1 insertion(+), 53 deletions(-) diff --git a/src/libstd/old_iter.rs b/src/libstd/old_iter.rs index e0a01a41f0a..9fea4376816 100644 --- a/src/libstd/old_iter.rs +++ b/src/libstd/old_iter.rs @@ -59,13 +59,6 @@ pub trait CopyableOrderedIter { fn max(&self) -> A; } -pub trait CopyableNonstrictIter { - // 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 { diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index c61995619a4..61b8d36266e 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -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}; diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index b5ae605e03c..91e94f7dcf8 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -2630,41 +2630,6 @@ impl old_iter::CopyableOrderedIter for @[A] { fn max(&self) -> A { old_iter::max(self) } } -impl<'self,A:Copy> old_iter::CopyableNonstrictIter 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 old_iter::CopyableNonstrictIter 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 old_iter::CopyableNonstrictIter 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 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); - } }