Get active features dynamically by their Symbol
This commit is contained in:
parent
3964a55ba5
commit
8f3021bd2c
1 changed files with 12 additions and 0 deletions
|
|
@ -53,6 +53,18 @@ macro_rules! declare_features {
|
|||
$(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…
Add table
Add a link
Reference in a new issue