Skip to main content

HashFields

Derive Macro HashFields 

Source
#[derive(HashFields)]
Expand description

Create a hashmap from the fields of an enum.

ยงExample to_hashmap

use small_iter_fields::{HashFields, IterFields};
 
#[derive(IterFields, HashFields, Hash, PartialEq, Eq)]
enum Stage {
    Start,
    Middle,
    End,
}
 
let map: std::collections::HashMap<Stage, Vec<i32>> = Stage::to_hashmap(Vec::new());
let set: std::collections::HashSet<Stage> = Stage::to_hashset();