Skip to content

Commit d09f569

Browse files
committed
auto merge of #9065 : thestinger/rust/iter, r=alexcrichton
The trait will keep the `Iterator` naming, but a more concise module name makes using the free functions less verbose. The module will define iterables in addition to iterators, as it deals with iteration in general.
2 parents eae3270 + 6919cf5 commit d09f569

Some content is hidden

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

48 files changed

+89
-95
lines changed

doc/tutorial-container.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ for i in range(0, 5) {
200200
printf!("%d ", i) // prints "0 1 2 3 4"
201201
}
202202

203-
for i in std::iterator::range_inclusive(0, 5) { // needs explicit import
203+
for i in std::iter::range_inclusive(0, 5) { // needs explicit import
204204
printf!("%d ", i) // prints "0 1 2 3 4 5"
205205
}
206206
~~~

src/etc/unicode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def emit_decomp_module(f, canon, compat, combine):
310310
+ " bsearch_range_value_table(c, combining_class_table)\n"
311311
+ " }\n\n")
312312
f.write(" fn d(c: char, i: &fn(char), k: bool) {\n")
313-
f.write(" use iterator::Iterator;\n");
313+
f.write(" use iter::Iterator;\n");
314314

315315
f.write(" if c <= '\\x7f' { i(c); return; }\n")
316316

src/libextra/bitv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313

1414
use std::cmp;
15-
use std::iterator::RandomAccessIterator;
16-
use std::iterator::{Invert, Enumerate, Repeat, Map, Zip};
15+
use std::iter::RandomAccessIterator;
16+
use std::iter::{Invert, Enumerate, Repeat, Map, Zip};
1717
use std::num;
1818
use std::ops;
1919
use std::uint;

src/libextra/dlist.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
use std::cast;
2626
use std::ptr;
2727
use std::util;
28-
use std::iterator::{FromIterator, Extendable, Invert};
29-
use std::iterator;
28+
use std::iter::Invert;
29+
use std::iter;
3030

3131
use container::Deque;
3232

@@ -593,27 +593,27 @@ impl<A> Extendable<A> for DList<A> {
593593
impl<A: Eq> Eq for DList<A> {
594594
fn eq(&self, other: &DList<A>) -> bool {
595595
self.len() == other.len() &&
596-
iterator::order::eq(self.iter(), other.iter())
596+
iter::order::eq(self.iter(), other.iter())
597597
}
598598

599599
fn ne(&self, other: &DList<A>) -> bool {
600600
self.len() != other.len() ||
601-
iterator::order::ne(self.iter(), other.iter())
601+
iter::order::ne(self.iter(), other.iter())
602602
}
603603
}
604604

605605
impl<A: Eq + Ord> Ord for DList<A> {
606606
fn lt(&self, other: &DList<A>) -> bool {
607-
iterator::order::lt(self.iter(), other.iter())
607+
iter::order::lt(self.iter(), other.iter())
608608
}
609609
fn le(&self, other: &DList<A>) -> bool {
610-
iterator::order::le(self.iter(), other.iter())
610+
iter::order::le(self.iter(), other.iter())
611611
}
612612
fn gt(&self, other: &DList<A>) -> bool {
613-
iterator::order::gt(self.iter(), other.iter())
613+
iter::order::gt(self.iter(), other.iter())
614614
}
615615
fn ge(&self, other: &DList<A>) -> bool {
616-
iterator::order::ge(self.iter(), other.iter())
616+
iter::order::ge(self.iter(), other.iter())
617617
}
618618
}
619619

src/libextra/enum_set.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::iterator::Iterator;
12-
1311
#[deriving(Clone, Eq, IterBytes, ToStr)]
1412
/// A specialized Set implementation to use enum types.
1513
pub struct EnumSet<E> {

src/libextra/json.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
1919
use std::char;
2020
use std::cast::transmute;
21-
use std::iterator;
2221
use std::float;
2322
use std::hashmap::HashMap;
2423
use std::io::WriterUtil;
@@ -489,7 +488,7 @@ pub struct Parser<T> {
489488
}
490489

491490
/// Decode a json value from an Iterator<char>
492-
pub fn Parser<T : iterator::Iterator<char>>(rdr: ~T) -> Parser<T> {
491+
pub fn Parser<T : Iterator<char>>(rdr: ~T) -> Parser<T> {
493492
let mut p = Parser {
494493
rdr: rdr,
495494
ch: '\x00',
@@ -500,7 +499,7 @@ pub fn Parser<T : iterator::Iterator<char>>(rdr: ~T) -> Parser<T> {
500499
p
501500
}
502501

503-
impl<T: iterator::Iterator<char>> Parser<T> {
502+
impl<T: Iterator<char>> Parser<T> {
504503
pub fn parse(&mut self) -> Result<Json, Error> {
505504
match self.parse_value() {
506505
Ok(value) => {
@@ -518,7 +517,7 @@ impl<T: iterator::Iterator<char>> Parser<T> {
518517
}
519518
}
520519

521-
impl<T : iterator::Iterator<char>> Parser<T> {
520+
impl<T : Iterator<char>> Parser<T> {
522521
// FIXME: #8971: unsound
523522
fn eof(&self) -> bool { self.ch == unsafe { transmute(-1u32) } }
524523

src/libextra/num/bigint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,13 +2011,13 @@ mod bigint_tests {
20112011
#[cfg(test)]
20122012
mod bench {
20132013
use super::*;
2014-
use std::{iterator, util};
2014+
use std::{iter, util};
20152015
use std::num::{Zero, One};
20162016
use extra::test::BenchHarness;
20172017

20182018
fn factorial(n: uint) -> BigUint {
20192019
let mut f: BigUint = One::one();
2020-
for i in iterator::range_inclusive(1, n) {
2020+
for i in iter::range_inclusive(1, n) {
20212021
f = f * BigUint::from_uint(i);
20222022
}
20232023
f

src/libextra/priority_queue.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::clone::Clone;
1616
use std::unstable::intrinsics::{move_val_init, init};
1717
use std::util::{replace, swap};
1818
use std::vec;
19-
use std::iterator::{FromIterator, Extendable};
2019

2120
/// A priority queue implemented with a binary heap
2221
#[deriving(Clone)]

src/libextra/ringbuf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
use std::num;
1717
use std::vec;
18-
use std::iterator::{FromIterator, Invert, RandomAccessIterator, Extendable};
18+
use std::iter::{Invert, RandomAccessIterator};
1919

2020
use container::Deque;
2121

@@ -694,13 +694,13 @@ mod tests {
694694

695695
#[test]
696696
fn test_from_iterator() {
697-
use std::iterator;
697+
use std::iter;
698698
let v = ~[1,2,3,4,5,6,7];
699699
let deq: RingBuf<int> = v.iter().map(|&x| x).collect();
700700
let u: ~[int] = deq.iter().map(|&x| x).collect();
701701
assert_eq!(u, v);
702702

703-
let mut seq = iterator::count(0u, 2).take(256);
703+
let mut seq = iter::count(0u, 2).take(256);
704704
let deq: RingBuf<uint> = seq.collect();
705705
for (i, &x) in deq.iter().enumerate() {
706706
assert_eq!(2*i, x);

src/libextra/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#[allow(missing_doc)];
1717

18-
use std::iterator::{Iterator, Enumerate, FilterMap, Invert};
18+
use std::iter::{Enumerate, FilterMap, Invert};
1919
use std::util::replace;
2020
use std::vec::{VecIterator, VecMutIterator};
2121
use std::vec;

src/libextra/treemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515

1616
use std::util::{swap, replace};
17-
use std::iterator::{FromIterator, Extendable, Peekable};
17+
use std::iter::{Peekable};
1818
use std::cmp::Ordering;
1919

2020
// This is implemented as an AA tree, which is a simplified variation of

src/librustc/middle/check_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use middle::typeck::method_map;
1818
use middle::moves;
1919
use util::ppaux::ty_to_str;
2020

21-
use std::iterator;
21+
use std::iter;
2222
use std::num;
2323
use std::vec;
2424
use extra::sort;
@@ -282,7 +282,7 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
282282
_ => max_len
283283
}
284284
};
285-
for n in iterator::range(0u, max_len + 1) {
285+
for n in iter::range(0u, max_len + 1) {
286286
match is_useful_specialized(cx, m, v, vec(n), n, left_ty) {
287287
not_useful => (),
288288
ref u => return *u,

src/librustc/middle/trans/basic_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use lib::llvm::{llvm, BasicBlockRef};
1212
use middle::trans::value::{UserIterator, Value};
13-
use std::iterator::{Filter, Map};
13+
use std::iter::{Filter, Map};
1414

1515
pub struct BasicBlock(BasicBlockRef);
1616

src/libstd/at_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use clone::Clone;
1414
use container::Container;
15-
use iterator::Iterator;
15+
use iter::Iterator;
1616
use option::{Option, Some, None};
1717
use sys;
1818
use unstable::raw::Repr;

src/libstd/c_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
// except according to those terms.
1010

1111
use cast;
12-
use iterator::{Iterator,range};
12+
use iter::{Iterator, range};
1313
use libc;
1414
use ops::Drop;
1515
use option::{Option, Some, None};
1616
use ptr::RawPtr;
1717
use ptr;
1818
use str::StrSlice;
19-
use vec::{ImmutableVector,CopyableVector};
19+
use vec::{ImmutableVector, CopyableVector};
2020
use container::Container;
2121

2222
/// Resolution options for the `null_byte` condition

src/libstd/either.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use option::{Some, None};
1616
use clone::Clone;
1717
use container::Container;
1818
use cmp::Eq;
19-
use iterator::{Iterator, FilterMap};
19+
use iter::{Iterator, FilterMap};
2020
use result::Result;
2121
use result;
2222
use str::StrSlice;

src/libstd/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ macro_rules! upper_hex(($ty:ident, $into:ident) => {
812812
#[doc(hidden)]
813813
pub fn upperhex(buf: &[u8], f: &mut Formatter) {
814814
let mut local = [0u8, ..16];
815-
for i in ::iterator::range(0, buf.len()) {
815+
for i in ::iter::range(0, buf.len()) {
816816
local[i] = match buf[i] as char {
817817
'a' .. 'f' => (buf[i] - 'a' as u8) + 'A' as u8,
818818
c => c as u8,

src/libstd/fmt/parse.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use prelude::*;
1212

1313
use char;
1414
use str;
15-
use iterator;
1615

1716
condition! { pub parse_error: ~str -> (); }
1817

@@ -152,7 +151,7 @@ pub struct Parser<'self> {
152151
priv depth: uint,
153152
}
154153

155-
impl<'self> iterator::Iterator<Piece<'self>> for Parser<'self> {
154+
impl<'self> Iterator<Piece<'self>> for Parser<'self> {
156155
fn next(&mut self) -> Option<Piece<'self>> {
157156
match self.cur.clone().next() {
158157
Some((_, '#')) => { self.cur.next(); Some(CurrentArgument) }

src/libstd/hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#[allow(missing_doc)];
2323

2424
use container::Container;
25-
use iterator::Iterator;
25+
use iter::Iterator;
2626
use option::{Some, None};
2727
use rt::io::Writer;
2828
use str::OwnedStr;

src/libstd/hashmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
1919
use clone::Clone;
2020
use cmp::{Eq, Equiv};
2121
use hash::Hash;
22-
use iterator::{Iterator, FromIterator, Extendable};
23-
use iterator::{FilterMap, Chain, Repeat, Zip};
22+
use iter::{Iterator, FromIterator, Extendable};
23+
use iter::{FilterMap, Chain, Repeat, Zip};
2424
use num;
2525
use option::{None, Option, Some};
2626
use rand::RngUtil;

src/libstd/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use clone::Clone;
5252
use c_str::ToCStr;
5353
use container::Container;
5454
use int;
55-
use iterator::Iterator;
55+
use iter::Iterator;
5656
use libc::consts::os::posix88::*;
5757
use libc::{c_int, c_void, size_t};
5858
use libc;

src/libstd/iterator.rs renamed to src/libstd/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ pub trait Iterator<A> {
363363
/// # Example
364364
///
365365
/// ~~~ {.rust}
366-
/// use std::iterator::Counter;
366+
/// use std::iter::count;
367367
///
368368
/// for i in count(0, 10) {
369369
/// printfln!("%d", i);
@@ -754,7 +754,7 @@ pub trait MultiplicativeIterator<A> {
754754
/// # Example
755755
///
756756
/// ~~~ {.rust}
757-
/// use std::iterator::Counter;
757+
/// use std::iter::count;
758758
///
759759
/// fn factorial(n: uint) -> uint {
760760
/// count(1u, 1).take_while(|&i| i <= n).product()

src/libstd/option.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ use clone::Clone;
4545
use cmp::{Eq,Ord};
4646
use util;
4747
use num::Zero;
48-
use iterator;
49-
use iterator::{Iterator, DoubleEndedIterator, ExactSize};
48+
use iter;
49+
use iter::{Iterator, DoubleEndedIterator, ExactSize};
5050
use str::{StrSlice, OwnedStr};
5151
use to_str::ToStr;
5252
use clone::DeepClone;
@@ -60,19 +60,19 @@ pub enum Option<T> {
6060

6161
impl<T: Eq + Ord> Ord for Option<T> {
6262
fn lt(&self, other: &Option<T>) -> bool {
63-
iterator::order::lt(self.iter(), other.iter())
63+
iter::order::lt(self.iter(), other.iter())
6464
}
6565

6666
fn le(&self, other: &Option<T>) -> bool {
67-
iterator::order::le(self.iter(), other.iter())
67+
iter::order::le(self.iter(), other.iter())
6868
}
6969

7070
fn ge(&self, other: &Option<T>) -> bool {
71-
iterator::order::ge(self.iter(), other.iter())
71+
iter::order::ge(self.iter(), other.iter())
7272
}
7373

7474
fn gt(&self, other: &Option<T>) -> bool {
75-
iterator::order::gt(self.iter(), other.iter())
75+
iter::order::gt(self.iter(), other.iter())
7676
}
7777
}
7878

src/libstd/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use c_str::ToCStr;
3232
use clone::Clone;
3333
use container::Container;
3434
use io;
35-
use iterator::range;
35+
use iter::range;
3636
use libc;
3737
use libc::{c_char, c_void, c_int, size_t};
3838
use libc::FILE;

src/libstd/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use c_str;
2121
use clone::Clone;
2222
use cmp::Eq;
2323
use container::Container;
24-
use iterator::{Iterator, range};
24+
use iter::{Iterator, range};
2525
use libc;
2626
use num;
2727
use option::{None, Option, Some};

src/libstd/prelude.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub use result::{Result, Ok, Err};
4040

4141
// Reexported functions
4242
pub use io::{print, println};
43-
pub use iterator::range;
43+
pub use iter::range;
4444
pub use from_str::from_str;
4545

4646
// Reexported types and traits
@@ -51,9 +51,9 @@ pub use char::Char;
5151
pub use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
5252
pub use hash::Hash;
5353
pub use num::Times;
54-
pub use iterator::{FromIterator, Extendable};
55-
pub use iterator::{Iterator, DoubleEndedIterator, RandomAccessIterator, ClonableIterator};
56-
pub use iterator::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
54+
pub use iter::{FromIterator, Extendable};
55+
pub use iter::{Iterator, DoubleEndedIterator, RandomAccessIterator, ClonableIterator};
56+
pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
5757
pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul};
5858
pub use num::{Orderable, Signed, Unsigned, Round};
5959
pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};

0 commit comments

Comments
 (0)