Skip to main content

StableHash

Derive Macro StableHash 

Source
#[derive(StableHash)]
Expand description

Implement StableHash for a struct or enum, assuming every field’s type already implements it. For an enum, the matched variant’s discriminant is also mixed into the hash.

This also registers the impl with type_to_trait!.

Usage:

use pliron::{derive::StableHash, r#type::TypeHandle};

#[derive(StableHash)]
struct MyAttr {
    ty: TypeHandle,
    val: u64,
}

This fails to compile because NotHashable doesn’t implement StableHash:

use pliron::derive::StableHash;

struct NotHashable;

#[derive(StableHash)]
struct MyAttr {
    val: NotHashable,
}