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
17
18
#![allow(dead_code)]

use const_struct_version::StructVersion;

#[derive(StructVersion)]
struct GenericContainer<T> {
    value: T,
    items: Vec<T>,
}

#[derive(StructVersion)]
struct ConcreteType {
    data: GenericContainer<u32>,
}

fn test_generic_struct() {
    let version = <ConcreteType as StructVersion>::version();
}