Skip to content

Commit 7b7a0fc

Browse files
committed
auto merge of #6056 : thestinger/rust/iter, r=catamorphism
The existing adaptors like `map` in the `iter` module are very flawed because they only work for `BaseIter` implementations. There are many internal iterator implementations in the standard library like the set methods (`difference`, `symmetric_difference`, `intersection`, `union`) and the `range` functions that only share the `for` loop protocol in common. The internal iterator adaptors should be implemented to work on any implementation of that protocol, rather than just a method called `each` taking `&self`. This just moves `iter.rs` to `old_iter.rs` and begins work on documenting and implementing a nicer module.
2 parents 9f03d45 + 46f91a0 commit 7b7a0fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+626
-518
lines changed

doc/tutorial.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ struct TimeBomb {
19811981
19821982
impl Drop for TimeBomb {
19831983
fn finalize(&self) {
1984-
for iter::repeat(self.explosivity) {
1984+
for old_iter::repeat(self.explosivity) {
19851985
io::println("blam!");
19861986
}
19871987
}

src/libcore/at_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use cast::transmute;
1414
use kinds::Copy;
15-
use iter;
15+
use old_iter;
1616
use option::Option;
1717
use ptr::addr_of;
1818
use sys;
@@ -125,7 +125,7 @@ pub fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
125125
* Creates an immutable vector of size `n_elts` and initializes the elements
126126
* to the value returned by the function `op`.
127127
*/
128-
pub fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
128+
pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> @[T] {
129129
do build_sized(n_elts) |push| {
130130
let mut i: uint = 0u;
131131
while i < n_elts { push(op(i)); i += 1u; }

src/libcore/core.rc

+5-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ pub use container::{Container, Mutable};
9999
pub use vec::{CopyableVector, ImmutableVector};
100100
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
101101
pub use vec::{OwnedVector, OwnedCopyableVector, MutableVector};
102-
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
103-
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
104-
pub use iter::{ExtendedMutableIter};
102+
pub use old_iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
103+
pub use old_iter::{CopyableOrderedIter, CopyableNonstrictIter};
104+
pub use old_iter::{ExtendedMutableIter};
105+
pub use iter::Times;
105106

106107
pub use num::{Num, NumCast};
107108
pub use num::{Orderable, Signed, Unsigned, Integer};
@@ -188,6 +189,7 @@ pub mod from_str;
188189
#[path = "num/num.rs"]
189190
pub mod num;
190191
pub mod iter;
192+
pub mod old_iter;
191193
pub mod iterator;
192194
pub mod to_str;
193195
pub mod to_bytes;

src/libcore/hashmap.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
use container::{Container, Mutable, Map, Set};
1717
use cmp::{Eq, Equiv};
1818
use hash::Hash;
19-
use iter::BaseIter;
19+
use old_iter::BaseIter;
2020
use hash::Hash;
21-
use iter;
21+
use old_iter;
2222
use option::{None, Option, Some};
2323
use rand::RngUtil;
2424
use rand;
@@ -757,12 +757,12 @@ impl<T:Hash + Eq> Set<T> for HashSet<T> {
757757
/// Return true if the set has no elements in common with `other`.
758758
/// This is equivalent to checking for an empty intersection.
759759
fn is_disjoint(&self, other: &HashSet<T>) -> bool {
760-
iter::all(self, |v| !other.contains(v))
760+
old_iter::all(self, |v| !other.contains(v))
761761
}
762762

763763
/// Return true if the set is a subset of another
764764
fn is_subset(&self, other: &HashSet<T>) -> bool {
765-
iter::all(self, |v| other.contains(v))
765+
old_iter::all(self, |v| other.contains(v))
766766
}
767767

768768
/// Return true if the set is a superset of another

0 commit comments

Comments
 (0)