Fixups
This commit is contained in:
@@ -19,9 +19,12 @@ implementing the `Iterator` trait.
|
||||
|
||||
use cmp;
|
||||
use iter;
|
||||
use iter::FromIter;
|
||||
use iter::{FromIter, Times};
|
||||
use num::{Zero, One};
|
||||
use prelude::*;
|
||||
use option::{Option, Some, None};
|
||||
use ops::{Add, Mul};
|
||||
use cmp::Ord;
|
||||
use clone::Clone;
|
||||
|
||||
/// An interface for dealing with "external iterators". These types of iterators
|
||||
/// can be resumed at any time as all state is stored internally as opposed to
|
||||
@@ -871,9 +874,9 @@ mod tests {
|
||||
use uint;
|
||||
|
||||
#[test]
|
||||
fn test_counter_to_vec() {
|
||||
fn test_counter_from_iter() {
|
||||
let mut it = Counter::new(0, 5).take(10);
|
||||
let xs = iter::to_vec(|f| it.advance(f));
|
||||
let xs: ~[int] = iter::FromIter::from_iter::<int, ~[int]>(|f| it.advance(f));
|
||||
assert_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
|
||||
}
|
||||
|
||||
@@ -904,7 +907,7 @@ mod tests {
|
||||
fn test_filter_map() {
|
||||
let mut it = Counter::new(0u, 1u).take(10)
|
||||
.filter_map(|x: uint| if x.is_even() { Some(x*x) } else { None });
|
||||
assert_eq!(it.to_vec(), ~[0*0, 2*2, 4*4, 6*6, 8*8]);
|
||||
assert_eq!(it.collect::<~[uint]>(), ~[0*0, 2*2, 4*4, 6*6, 8*8]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1065,7 +1068,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_collect() {
|
||||
let a = [1, 2, 3, 4, 5];
|
||||
let a = ~[1, 2, 3, 4, 5];
|
||||
let b: ~[int] = a.iter().transform(|&x| x).collect();
|
||||
assert_eq!(a, b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user