2 use std::collections::BTreeSet;
6 let mut x = BTreeSet::new();
7 let mut y = BTreeSet::new();
17 assert_eq!(hash(&x), hash(&y));
21 fn test_prefix_free() {
22 let x = BTreeSet::from([1, 2, 3]);
23 let y = BTreeSet::<i32>::new();
25 // If hashed by iteration alone, `(x, y)` and `(y, x)` would visit the same
26 // order of elements, resulting in the same hash. But now that we also hash
27 // the length, they get distinct sequences of hashed data.
28 assert_ne!(hash(&(&x, &y)), hash(&(&y, &x)));