I have a struct as following:
struct Ingredient {
name: String,
alias: String,
... //other data
}
I want to use this struct as key of two HashMap
, one only compares field name
, and another only compares field alias
.
h_name: HashMap<Ingredient, usize> = HashMap::new();
h_alias: HashMap<Ingredient, usize> = HashMap::new();
How can I implement it? I dont want to split this struct to two structs because many fields are tightly coupled.