-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Clean up libcollections::VecMap
#19663
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
- Introduce a named type for the return type of `VecMap::move_iter` - Rename all type parameters to `V` for "Value". - Remove unnecessary call to an `Option::unwrap`, use pattern matching instead. - Remove incorrect `Hash` implementation which took the `VecMap`'s capacity into account. This is a [breaking-change], however whoever used the `Hash` implementation relied on an incorrect implementation.
@@ -921,23 +919,6 @@ mod test_map { | |||
} | |||
|
|||
#[test] | |||
fn test_hash() { |
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.
Uh... why delete the entire test?
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.
Oh you straight-up deleted the Hash impl. That seems wrong?
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.
You should be able to steal the Hash impl from e.g. RingBuf. Just hash the contents of the iterator.
Also re-add the previously deleted test with an additional test that would have failed before, when the hash function depended on the capacity.
pub type Values<'a, T> = | ||
iter::Map<'static, (uint, &'a T), &'a T, Entries<'a, T>>; | ||
pub type Values<'a, V> = | ||
iter::Map<'static, (uint, &'a V), &'a V, Entries<'a, V>>; |
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 vaguely concerned that these are typedefs instead of wrapper structs. Are we sure we're never going to want to change the implementations of these iterators such that this signature will change?
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.
Yes that's the more correct solution, longterm. If @tbu- is willing to make that change in this PR I would be happy to re-r.
- Introduce a named type for the return type of `VecMap::move_iter` - Rename all type parameters to `V` for "Value". - Remove unnecessary call to an `Option::unwrap`, use pattern matching instead. - Remove incorrect `Hash` implementation which took the `VecMap`'s capacity into account. This is a [breaking-change], however whoever used the `Hash` implementation relied on an incorrect implementation.
As mentioned in rust-lang#19663, it is more desirable long-term that iterators be implemented as wrapper structs instead of typedefs. This pull request converts `VecMap` to the preferred solution.
VecMap::move_iter
V
for "Value".Option::unwrap
, use pattern matching instead.Hash
implementation which took theVecMap
's capacityinto account.
This is a [breaking-change], however whoever used the
Hash
implementationrelied on an incorrect implementation.