-
Notifications
You must be signed in to change notification settings - Fork 50
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
incorrect hash impl #72
Comments
I discovered this while trying to move |
Hm, is that actually We could unroll the call here in this crate, but it does seem surprising that that's considered different in terms of hash output. |
https://doc.rust-lang.org/std/hash/trait.Hasher.html
|
I was thinking the other way around, making Ascii turn write_u8(b) into write(std::slice::from_ref(&b)) but I don't know for certain if that is sufficient. |
The fastest compatible implementation for both would be to turn the strings into 4-byte codepoints and hashing the stream of codepoints using |
That sounds undesirable to me, because many characters are just 1 byte, perhaps 2, but that would require hashing 4 for every character. I'm thinking of just adding a loop on the bytes instead. |
https://doc.rust-lang.org/std/hash/trait.Hash.html#hash-and-eq
UniCase<S: AsRef<str>>
implementsHash + Eq
, so the above requirement must be satisfied. The following test case fails:This occurs because
UniCase::unicode
producesb"f", b"o", b"o"
, whileUniCase::new
(with ascii) producesb'f', b'o', b'o'
, which is not guaranteed to be the same underHasher
.The text was updated successfully, but these errors were encountered: