Get active features dynamically by their `Symbol`
This commit is contained in:
parent
3964a55ba5
commit
8f3021bd2c
|
@ -53,6 +53,18 @@ macro_rules! declare_features {
|
||||||
$(f(stringify!($feature), self.$feature);)+
|
$(f(stringify!($feature), self.$feature);)+
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::ops::Index<Symbol> for Features {
|
||||||
|
type Output = bool;
|
||||||
|
|
||||||
|
fn index(&self, feature: Symbol) -> &Self::Output {
|
||||||
|
match feature {
|
||||||
|
$( sym::$feature => &self.$feature, )*
|
||||||
|
|
||||||
|
_ => panic!("{} was not defined in `declare_features`", feature),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue