From 0c02d0f92ecabb9486482c3e4d660e736346803b Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Wed, 8 May 2013 18:49:32 -0400 Subject: [PATCH] rename iter::iter_to_vec to iter::to_vec it's silly to duplicate the namespace in the fn name --- src/libcore/iter.rs | 11 +++++------ src/libcore/iterator.rs | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 8fc2db6d6f19..b68d11583349 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -17,8 +17,7 @@ breaking out of iteration. The adaptors in the module work with any such iterato tied to specific traits. For example: ~~~~ -use core::iter::iter_to_vec; -println(iter_to_vec(|f| uint::range(0, 20, f)).to_str()); +println(iter::to_vec(|f| uint::range(0, 20, f)).to_str()); ~~~~ An external iterator object implementing the interface in the `iterator` module can be used as an @@ -55,12 +54,12 @@ pub trait Times { * * ~~~ * let xs = ~[1, 2, 3]; - * let ys = do iter_to_vec |f| { xs.each(|x| f(*x)) }; + * let ys = do iter::to_vec |f| { xs.each(|x| f(*x)) }; * assert_eq!(xs, ys); * ~~~ */ #[inline(always)] -pub fn iter_to_vec(iter: &fn(f: &fn(T) -> bool)) -> ~[T] { +pub fn to_vec(iter: &fn(f: &fn(T) -> bool)) -> ~[T] { let mut v = ~[]; for iter |x| { v.push(x) } v @@ -185,9 +184,9 @@ mod tests { use prelude::*; #[test] - fn test_iter_to_vec() { + fn test_to_vec() { let xs = ~[1, 2, 3]; - let ys = do iter_to_vec |f| { xs.each(|x| f(*x)) }; + let ys = do to_vec |f| { xs.each(|x| f(*x)) }; assert_eq!(xs, ys); } diff --git a/src/libcore/iterator.rs b/src/libcore/iterator.rs index 5e95485b2736..29dd4538aa25 100644 --- a/src/libcore/iterator.rs +++ b/src/libcore/iterator.rs @@ -378,7 +378,7 @@ mod tests { #[test] fn test_counter_to_vec() { let mut it = Counter::new(0, 5).take(10); - let xs = iter::iter_to_vec(|f| it.advance(f)); + let xs = iter::to_vec(|f| it.advance(f)); assert_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]); }