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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user