const-struct-version 0.2.0

A trait plus proc-macro to generate a hash based on the fields of a struct. Useful for intelligently expiring a cache when the stored object changes.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![allow(dead_code)]

use const_struct_version::StructVersion;

#[derive(StructVersion)]
struct TreeNode {
    value: i32,
    #[allow(clippy::vec_box)]
    children: Vec<Box<TreeNode>>,
}

#[test]
fn test_tree_node_works() {
    let version = <TreeNode as StructVersion>::version();
    insta::assert_debug_snapshot!(version);
}