-
Notifications
You must be signed in to change notification settings - Fork 298
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
impls of PartialEq<str> etc. violate Hash consistency #230
Comments
I think you may be referring to the relationship of |
Still, it's notable that the standard library does not mix |
@mzabaluev what do you propose should change? |
@carllerche I think the |
This seems reasonable to me. I flagged this issue as part of the v0.5 milestone. |
Unfortunately, deprecation of an impl does not work in current Rust. So it should either be a hard break in 0.5, or some shim methods to show a deprecation warning meant for the impls. |
I personally would prefer not to remove the impls, they are useful and I don't believe they cause an issue in practice. |
@seanmonstar should we not stick w/ what std does? |
For full disclosure, I have a pending RFC that, if accepted, will discourage binary operator impls across types not sharing the |
The convenience provided by the impls in question is, basically, in not having to add an |
I've found these impls provide a nicer experience than when I'm working with I'm not willing to die on this hill, I just feel like it improves my experience and would be sad to see it go. |
After discussing this, the plan is to stick w/ std. |
This test currently fails:
For things to be proper, this test should not even compile due to lack of an equality impl.
The
PartialEq
implementations that make the equality operators work between aBytes
value and a string, while convenient, allow two logically equal values to have different hashes. This violates the contract ofHash
and therefore is a no-no. The standard library avoids pairing strings and byte slices in equality and comparison operators, and even burns extra CPU to make a string'sHash
output pointedly different from that of an equivalent byte slice.This issue does not affect
HashTable
because there is noBorrow
impl to cross between the key types. But the inconsistency is lurking and can bite even in generic code usingHash
by the book.The text was updated successfully, but these errors were encountered: