Add EMPTY_FLAGS to flags generator

This seems like a useful primitive to have especially when dealing
with `Rights` flags in `wasi-common` (and WASI in general).
This commit is contained in:
Jakub Konka
2020-02-28 21:15:22 +01:00
committed by Jakub Konka
parent 974f5617e0
commit 5db335b7c7

View File

@@ -35,10 +35,11 @@ pub(super) fn define_flags(names: &Names, name: &witx::Id, f: &witx::FlagsDataty
impl #ident {
#(#flag_constructors);*;
pub const EMPTY_FLAGS: #ident = #ident(0 as #repr);
pub const ALL_FLAGS: #ident = #ident(#all_values_token);
pub fn contains(&self, other: &#ident) -> bool {
#repr::from(!*self & *other) == 0 as #repr
!*self & *other == Self::EMPTY_FLAGS
}
}