Skip to content

Commit 8f3021b

Browse files
Get active features dynamically by their Symbol
1 parent 3964a55 commit 8f3021b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustc_feature/active.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ macro_rules! declare_features {
5353
$(f(stringify!($feature), self.$feature);)+
5454
}
5555
}
56+
57+
impl std::ops::Index<Symbol> for Features {
58+
type Output = bool;
59+
60+
fn index(&self, feature: Symbol) -> &Self::Output {
61+
match feature {
62+
$( sym::$feature => &self.$feature, )*
63+
64+
_ => panic!("{} was not defined in `declare_features`", feature),
65+
}
66+
}
67+
}
5668
};
5769
}
5870

0 commit comments

Comments
 (0)