diff options
Diffstat (limited to 'src/libstd/iter.rs')
| -rw-r--r-- | src/libstd/iter.rs | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index fde27a6fc09..9a50b8a6741 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -51,16 +51,17 @@ pub trait Times { fn times(&self, it: &fn() -> bool) -> bool; } +#[allow(missing_doc)] pub trait FromIter<T> { - // Build a container with elements from an internal iterator. - // - // # Example: - // - // ~~~ {.rust} - // let xs = ~[1, 2, 3]; - // let ys: ~[int] = do FromIter::from_iter |f| { xs.each(|x| f(*x)) }; - // assert_eq!(xs, ys); - // ~~~ + /// Build a container with elements from an internal iterator. + /// + /// # Example: + /// + /// ~~~ {.rust} + /// let xs = ~[1, 2, 3]; + /// let ys: ~[int] = do FromIter::from_iter |f| { xs.each(|x| f(*x)) }; + /// assert_eq!(xs, ys); + /// ~~~ pub fn from_iter(iter: &fn(f: &fn(T) -> bool) -> bool) -> Self; } @@ -75,22 +76,6 @@ impl<T> FromIter<T> for ~[T]{ } /** - * Transform an internal iterator into an owned vector. - * - * # Example: - * - * ~~~ {.rust} - * let xs = ~[1, 2, 3]; - * let ys = do iter::to_vec |f| { xs.each(|x| f(*x)) }; - * assert_eq!(xs, ys); - * ~~~ - */ -#[inline(always)] -pub fn to_vec<T>(iter: &fn(f: &fn(T) -> bool) -> bool) -> ~[T] { - FromIter::from_iter(iter) -} - -/** * Return true if `predicate` is true for any values yielded by an internal iterator. * * Example: @@ -283,15 +268,8 @@ mod tests { use uint; #[test] - fn test_to_vec() { - let xs = ~[1, 2, 3]; - let ys = do to_vec |f| { xs.each(|x| f(*x)) }; - assert_eq!(xs, ys); - } - - #[test] fn test_from_iter() { - let xs: ~[int] = ~[1, 2, 3]; + let xs: = ~[1, 2, 3]; let ys: ~[int] = do FromIter::from_iter |f| { xs.each(|x| f(*x)) }; assert_eq!(xs, ys); } |
