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]
This commit is contained in:
parent
1bc29924dc
commit
1bde6e3fcb
21 changed files with 78 additions and 83 deletions
|
@ -32,7 +32,7 @@ pub struct Toc {
|
|||
|
||||
impl Toc {
|
||||
fn count_entries_with_level(&self, level: u32) -> uint {
|
||||
self.entries.iter().count(|e| e.level == level)
|
||||
self.entries.iter().filter(|e| e.level == level).count()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue