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

Implement Hash and PartialOrd for RingBuf #16020

Merged
merged 3 commits into from
Jul 27, 2014
Merged

Conversation

nham
Copy link
Contributor

@nham nham commented Jul 27, 2014

cc #15294

elt.hash(state);
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in general collections need to hash their length first because otherwise this would have the same hash:

  • (vec![1], vec![2, 3])
  • (vec![1, 2], vec![3])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I didn't' think of that. That means that some of the other Hash implementations I've done are wrong. TreeMap at least seems to be wrong. Though I'm wondering if that could be fixed at the tuple-level. (Tuples could hash the index before each value?)

I've fixed it for RingBuf here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I think it's ok, they can be amended in the future. Hashing to the same value isn't really the end of the world, so long as the comparisons are correct!

@bors bors closed this Jul 27, 2014
@bors bors merged commit 9fa4424 into rust-lang:master Jul 27, 2014
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.

3 participants