about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-06-05 23:18:51 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-06-06 19:51:31 -0700
commit1bde6e3fcb32ca00cf8a8dfa0977e47f7f4a77bf (patch)
treef5b2c5f46adc3cdc83e596445cc91e5112ea68b6 /src/libstd
parent1bc29924dc8f88c2c118b688f25ffa7c6a212276 (diff)
downloadrust-1bde6e3fcb32ca00cf8a8dfa0977e47f7f4a77bf.tar.gz
rust-1bde6e3fcb32ca00cf8a8dfa0977e47f7f4a77bf.zip
Rename Iterator::len to count
This commit carries out the request from issue #14678:

> The method `Iterator::len()` is surprising, as all the other uses of
> `len()` do not consume the value. `len()` would make more sense to be
> called `count()`, but that would collide with the current
> `Iterator::count(|T| -> bool) -> unit` method. That method, however, is
> a bit redundant, and can be easily replaced with
> `iter.filter(|x| x < 5).count()`.
> After this change, we could then define the `len()` method
> on `iter::ExactSize`.

Closes #14678.

[breaking-change]
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/num/strconv.rs1
-rw-r--r--src/libstd/rand/mod.rs12
-rw-r--r--src/libstd/rt/backtrace.rs2
3 files changed, 7 insertions, 8 deletions
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs
index 54ca5797804..133a8db90fa 100644
--- a/src/libstd/num/strconv.rs
+++ b/src/libstd/num/strconv.rs
@@ -13,7 +13,6 @@
 use char;
 use clone::Clone;
 use container::Container;
-use iter::Iterator;
 use num::{NumCast, Zero, One, cast, Int};
 use num::{Float, FPNaN, FPInfinite, ToPrimitive};
 use num;
diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs
index 61a2ffd383d..ee193562887 100644
--- a/src/libstd/rand/mod.rs
+++ b/src/libstd/rand/mod.rs
@@ -353,17 +353,17 @@ mod test {
     #[test]
     fn test_gen_ascii_str() {
         let mut r = task_rng();
-        assert_eq!(r.gen_ascii_chars().take(0).len(), 0u);
-        assert_eq!(r.gen_ascii_chars().take(10).len(), 10u);
-        assert_eq!(r.gen_ascii_chars().take(16).len(), 16u);
+        assert_eq!(r.gen_ascii_chars().take(0).count(), 0u);
+        assert_eq!(r.gen_ascii_chars().take(10).count(), 10u);
+        assert_eq!(r.gen_ascii_chars().take(16).count(), 16u);
     }
 
     #[test]
     fn test_gen_vec() {
         let mut r = task_rng();
-        assert_eq!(r.gen_iter::<u8>().take(0).len(), 0u);
-        assert_eq!(r.gen_iter::<u8>().take(10).len(), 10u);
-        assert_eq!(r.gen_iter::<f64>().take(16).len(), 16u);
+        assert_eq!(r.gen_iter::<u8>().take(0).count(), 0u);
+        assert_eq!(r.gen_iter::<u8>().take(10).count(), 10u);
+        assert_eq!(r.gen_iter::<f64>().take(16).count(), 16u);
     }
 
     #[test]
diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs
index ac421bf78be..fe6d84d4d2e 100644
--- a/src/libstd/rt/backtrace.rs
+++ b/src/libstd/rt/backtrace.rs
@@ -84,7 +84,7 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
             if i == 0 {
                 valid = chars.next().is_none();
                 break
-            } else if chars.by_ref().take(i - 1).len() != i - 1 {
+            } else if chars.by_ref().take(i - 1).count() != i - 1 {
                 valid = false;
             }
         }