Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement `Hash` for `Origin` (fix #302) #321
Conversation
skade
commented
May 5, 2017
|
@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! |
894bc2f
to
459904f
|
Thank you! I updated the PR to test hash values directly instead of using |
|
Test that things that compare equal with |
459904f
to
38104b5
|
What do you think about this? Are there enough URL samples? |
38104b5
to
dbe1980
|
|
e224f8c
to
7e9c87d
|
I solved the conflict with Tell me if there is anything left to do regarding this PR. |
dtolnay left a comment
|
Looks good to me. All of the feedback so far has been addressed. |
|
|
7e9c87d
to
4260325
|
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: |
|
Sorry for the delay @cGuille ! |
|
@bors-servo r=brson |
|
|
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 -->
|
|
cGuille commentedMay 5, 2017
•
edited by larsbergstrom
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
Hashfor theOrigintype.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