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 34ee57b commit 1fd00c1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2490,15 +2490,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 1fd00c1

Please sign in to comment.