-
Notifications
You must be signed in to change notification settings - Fork 346
Implement Hash
for Origin
(fix #302)
#321
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
Conversation
@cGuille Wait for one of the maintainers to provide review :). Most maintainers of the URL crate live in the US, so this might take until later. Ignore the nightly error in the linked travis test suite, rust nightly is currently broken, not this lib. |
@SimonSapin is french fwiw, hopefully he can take a look soon-ish. Can you test also that opaque origins get different hashes? (It's trivial, but worth having that in the test-suite too). |
Hello, There is actually no hurry at all. :-) I am OK with adding more tests ; I will just have to figure out how. |
@skade, unfortunately, most of the maintainers of the url crate are me :) I’m usually in UTC+1~2. @cGuille You can hash without a hashmap like so: use std::collections::hash_map::DefaultHasher;
use std::hash::Hash;
fn hash<T: Hash>(value: T) -> u64 {
let mut hasher = DefaultHasher::new();
value.hash(&mut hasher);
hasher.finish()
} To make the test more interesting, you could use different URLs that have the same origin. Please also test that hashing is consistent with Thanks! |
Thank you! I updated the PR to test hash values directly instead of using |
Test that things that compare equal with |
What do you think about this? Are there enough URL samples? |
☔ The latest upstream changes (presumably #306) made this pull request unmergeable. Please resolve the merge conflicts. |
I solved the conflict with Tell me if there is anything left to do regarding this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. All of the feedback so far has been addressed.
☔ The latest upstream changes (presumably #344) made this pull request unmergeable. Please resolve the merge conflicts. |
I rebased upon master to solve this second conflict. Can this be merged? |
@bors-servo r+ bors-servo probably doesn't listen to me... |
@brson: 🔑 Insufficient privileges: Not in reviewers |
Sorry for the delay @cGuille ! |
@bors-servo r=brson |
📌 Commit 4260325 has been approved by |
Implement `Hash` for `Origin` (fix #302) Hello, I'm a Rust / Open Source beginner, so just explain if anything is wrong. :-) I am giving a try at issue #302. I just derived the `Hash` for the `Origin` type. I have zero experience with testing in Rust so I just tried to demonstrate that it works, but I do not know how to write a good test for this. What should I do now? <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/321) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
Hello,
I'm a Rust / Open Source beginner, so just explain if anything is wrong. :-)
I am giving a try at issue #302. I just derived the
Hash
for theOrigin
type.I have zero experience with testing in Rust so I just tried to demonstrate that it works, but I do not know how to write a good test for this.
What should I do now?
This change is