Skip to content
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

Rename Iterator::len to count #14692

Closed
wants to merge 1 commit into from
Closed

Conversation

aturon
Copy link
Member

@aturon aturon commented Jun 6, 2014

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 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]
@huonw
Copy link
Member

huonw commented Jun 8, 2014

FWIW, I think this should've just deprecated .len and not added len to ExactSize immediately, especially since it can silently change behaviour (unlike almost all other breaking changes).

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 7, 2023
Exclude non-identifier aliases from completion filtering text

When building `CompletionItem`s, this excludes aliases that aren't valid identifiers from the "lookup" text used to filter completions in the LSP client. Including them results in weird completion filtering behavior e.g. `Partial>` matching a completion for the `PartialOrd` trait because it has a doc alias of ">".

Closes rust-lang#14692
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

It's surprising that Iterator::len consumes the iterator
3 participants