Add contains and intersects to the component-macro bindings for flags. (#5598)

In component-macro, when expanding the bindings for flags types, add
`contains` and `intersects` methods, for convenience.
This commit is contained in:
Dan Gohman
2023-01-19 09:27:42 -08:00
committed by GitHub
parent da03ff47f1
commit 56a981bdd8

View File

@@ -1114,6 +1114,14 @@ pub fn expand_flags(flags: &Flags) -> Result<TokenStream> {
use std::ops::Not;
Self::default().not()
}
pub fn contains(&self, other: Self) -> bool {
*self & other == other
}
pub fn intersects(&self, other: Self) -> bool {
*self & other != Self::empty()
}
}
impl std::cmp::PartialEq for #name {