Macro forest_filecoin::shim::fvm_latest::total_enum_map

source ·
macro_rules! total_enum_map {
    ($en:ident { $($item:ident => $value:expr),+ $(,)? }) => { ... };
}
Expand description

Create a mapping from enum items to values in a way that guarantees at compile time that we did not miss any member, in any of the prices, even if the enum gets a new member later.

§Example

use fvm::total_enum_map;
use std::collections::HashMap;

#[derive(Hash, Eq, PartialEq)]
enum Foo {
    Bar,
    Baz,
}

let foo_cost: HashMap<Foo, u8> = total_enum_map! {
    Foo {
        Bar => 10,
        Baz => 20
    }
};