-
Notifications
You must be signed in to change notification settings - Fork 13.3k
It's surprising that Iterator::len consumes the iterator #14678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
+1, this sounds great. |
+1 |
aturon
added a commit
to aturon/rust
that referenced
this issue
Jun 6, 2014
This commit carries out the request from issue rust-lang#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 rust-lang#14678. [breaking-change]
mcpherrinm
pushed a commit
to mcpherrinm/rust
that referenced
this issue
Jun 10, 2014
This commit carries out the request from issue rust-lang#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 rust-lang#14678. [breaking-change]
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Jun 5, 2023
fix: Fix restart server button trying to start instead of restart the server
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The method
Iterator::len()
is surprising, as all the other uses oflen()
do not consume the value.len()
would make more sense to be calledcount()
, but that would collide with the currentIterator::count(|T| -> bool) -> unit
method. That method, however, is a bit redundant, and can be easily replaced withiter.filter(|x| x < 5).count()
. After this change, we could then define thelen()
method oniter::ExactSize
.The text was updated successfully, but these errors were encountered: