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

Clean up libcollections::VecMap #19663

Merged
merged 2 commits into from
Dec 10, 2014
Merged

Clean up libcollections::VecMap #19663

merged 2 commits into from
Dec 10, 2014

Conversation

tbu-
Copy link
Contributor

@tbu- tbu- commented Dec 9, 2014

  • 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.

- 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() {
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

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>>;
Copy link
Member

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?

Copy link
Contributor

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.

bors added a commit that referenced this pull request Dec 10, 2014
- 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.
@bors bors closed this Dec 10, 2014
@bors bors merged commit 20eaf16 into rust-lang:master Dec 10, 2014
brson added a commit to brson/rust that referenced this pull request Dec 12, 2014
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.
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.

4 participants