Skip to content

SipHasher::write, when used externally, should refer to trait method, not inherent (and private) method. #28374

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

Closed
savv opened this issue Sep 12, 2015 · 1 comment

Comments

@savv
Copy link

savv commented Sep 12, 2015

This code snippet works: http://is.gd/cAKwYz

However, substituting ::Hasher for ::SipHasher gives the following error:

src/chunks.rs:35:5: 35:34 error: method `write` is private
src/chunks.rs:35     ::std::hash::SipHasher::write(&mut hasher, &x);

Discussion from IRC:

savv  hello. I am trying to figure out why SipHasher::write appears to be private, whereas ::finish is not: http://is.gd/cjwAvO
savv  Even though they both seem to be the same in terms of public-ness: https://doc.rust-lang.org/src/core/hash/sip.rs.html#174-200
eibwen  savv: it's because it has an inherent method of the same name
eibwen  savv: you need to call it via Hasher::write(&mut hasher, &x)
eibwen  you're welcome. you could open an issue about that
@savv
Copy link
Author

savv commented Sep 12, 2015

eibwen  savv: the problem is that SipHasher also defines its own "write" method, which is private
eibwen  savv: since that is an inherent method, it is preferred to a trait method, even though you can't access it

@savv savv changed the title SipHasher::write incorrectly marked as private SipHasher::write, when used externally, should refer to trait method, not inherent (and private) method. Sep 12, 2015
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

No branches or pull requests

2 participants