-
Notifications
You must be signed in to change notification settings - Fork 14k
Add ExactSizeIterator impls for Hash{Map, Set, Table} #20915
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
Conversation
This commit also changes the return types of all `size_hint()` impls in these files from (uint, Option<uint>) to (usize, Option<usize>).
|
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
|
r? @gankro |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is strictly necessary, but sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured I'd avoid the unnecessary size_hint() unwrap by just calling straight down, but these can be removed if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the strictly more correct thing, although if T: ExactSize, then size_hint is probably trivially inlineable to discard the upper-bound creation. This is fine as is; we need a better story for impl forwarding anyway (but thanks for soldiering through all this in the interim!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem! And I'll be happy to bring this in line with impl forwarding conventions if and when we get them if this happens to run afoul of them.
Add ExactSizeIterator impls for Hash{Map, Set, Table}
Reviewed-by: Gankro
…-let Fix not applicable on while for replace_is_method_with_if_let_method
…-let Fix not applicable on while for replace_is_method_with_if_let_method
Since
ExactSizeIteratorwas decoupled fromDoubleEndedIterator, it's now more or less "free" to implement ExactSizeIterator for these iterators. Not sure if this is even something that we want, but it was quick and easy enough to do that I thought I'd open a PR for it and see.This commit also changes the return types of all
size_hint()impls in these files from(uint, Option<uint>)to(usize, Option<usize>)since I was already in there and it's a closely related change.