object-hash 0.1.4

A stable hash of a structured value: the same value always hashes the same, whatever order its fields are in.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Runs the README example, so the documentation cannot drift from the API.

#[test]
fn readme_examples() {
    use object_hash::{Value, hash};

    let one = Value::Map(vec![
        ("name".into(), Value::String("cipansor".into())),
        ("year".into(), Value::Number(2026.0)),
    ]);
    // The same entries, inserted the other way round.
    let two = Value::Map(vec![
        ("year".into(), Value::Number(2026.0)),
        ("name".into(), Value::String("cipansor".into())),
    ]);

    assert_eq!(hash(&one), hash(&two));
}