Skip to content

Commit

Permalink
Eliminate hash closure in favor of calling hash_one directly
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 28, 2023
1 parent b9bcbad commit b328ee7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/test.rs
Expand Up @@ -2492,15 +2492,14 @@ fn test_value_into_deserializer() {
#[test]
fn hash_positive_and_negative_zero() {
let rand = std::hash::RandomState::new();
let hash = |obj| rand.hash_one(obj);

let k1 = serde_json::from_str::<Number>("0.0").unwrap();
let k2 = serde_json::from_str::<Number>("-0.0").unwrap();
if cfg!(feature = "arbitrary_precision") {
assert_ne!(k1, k2);
assert_ne!(hash(k1), hash(k2));
assert_ne!(rand.hash_one(k1), rand.hash_one(k2));
} else {
assert_eq!(k1, k2);
assert_eq!(hash(k1), hash(k2));
assert_eq!(rand.hash_one(k1), rand.hash_one(k2));
}
}

0 comments on commit b328ee7

Please sign in to comment.