diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-06-05 23:18:51 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-06-06 19:51:31 -0700 |
| commit | 1bde6e3fcb32ca00cf8a8dfa0977e47f7f4a77bf (patch) | |
| tree | f5b2c5f46adc3cdc83e596445cc91e5112ea68b6 /src/libcollections/vec.rs | |
| parent | 1bc29924dc8f88c2c118b688f25ffa7c6a212276 (diff) | |
| download | rust-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/libcollections/vec.rs')
| -rw-r--r-- | src/libcollections/vec.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index aa80a131811..6ca21262f51 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1772,23 +1772,23 @@ mod tests { assert_eq!(v.pop(), Some(())); assert_eq!(v.pop(), None); - assert_eq!(v.iter().len(), 0); + assert_eq!(v.iter().count(), 0); v.push(()); - assert_eq!(v.iter().len(), 1); + assert_eq!(v.iter().count(), 1); v.push(()); - assert_eq!(v.iter().len(), 2); + assert_eq!(v.iter().count(), 2); for &() in v.iter() {} - assert_eq!(v.mut_iter().len(), 2); + assert_eq!(v.mut_iter().count(), 2); v.push(()); - assert_eq!(v.mut_iter().len(), 3); + assert_eq!(v.mut_iter().count(), 3); v.push(()); - assert_eq!(v.mut_iter().len(), 4); + assert_eq!(v.mut_iter().count(), 4); for &() in v.mut_iter() {} unsafe { v.set_len(0); } - assert_eq!(v.mut_iter().len(), 0); + assert_eq!(v.mut_iter().count(), 0); } #[test] |
