Attribute Macro precompile_util_macro::generate_function_selector
source · #[generate_function_selector]
Expand description
This macro allows to associate to each variant of an enumeration a discriminant (of type u32 whose value corresponds to the first 4 bytes of the Hash Keccak256 of the character string indicated by the user of this macro.
Usage:
ⓘ
#[generate_function_selector]
enum Action {
Toto = "toto()",
Tata = "tata()",
}
Extended to:
#[repr(u32)]
enum Action {
Toto = 119097542u32,
Tata = 1414311903u32,
}