@@ -3,6 +3,7 @@ use crate::RawFlags;
33
44use super :: bindings:: tsk_flags_t;
55
6+ use std:: ops:: BitOr ;
67use std:: ops:: BitXorAssign ;
78
89macro_rules! make_constant_self {
@@ -38,7 +39,7 @@ macro_rules! flag_builder_api {
3839 ( $( #[ $attr: meta] ) * => $name: ident, $flag: ident) => {
3940 $( #[ $attr] ) *
4041 pub fn $name( self ) -> Self {
41- Self ( self . 0 | Self :: $flag)
42+ self | Self :: $flag
4243 }
4344 } ;
4445}
@@ -72,11 +73,26 @@ macro_rules! contains {
7273
7374macro_rules! impl_bit_ops {
7475 ( $type: ty) => {
75- impl std :: ops :: BitXorAssign for $type {
76+ impl BitXorAssign for $type {
7677 fn bitxor_assign( & mut self , rhs: Self ) {
7778 self . 0 ^= rhs. 0
7879 }
7980 }
81+
82+ impl BitOr for $type {
83+ type Output = Self ;
84+ fn bitor( self , rhs: Self ) -> Self :: Output {
85+ Self ( self . 0 | rhs. 0 )
86+ }
87+ }
88+ } ;
89+ }
90+
91+ macro_rules! flags_api {
92+ ( $type: ty) => {
93+ impl_flags!( $type) ;
94+ impl_from_for_flag_types!( $type) ;
95+ impl_bit_ops!( $type) ;
8096 } ;
8197}
8298
@@ -749,8 +765,6 @@ impl From<tsk_flags_t> for NodeFlags {
749765 }
750766}
751767
752- impl_bit_ops ! ( NodeFlags ) ;
753-
754768#[ derive( Default , Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
755769#[ repr( transparent) ]
756770/// Individual flags
@@ -770,25 +784,17 @@ impl IndividualFlags {
770784 contains ! ( ) ;
771785}
772786
773- impl_flags ! ( SimplificationOptions ) ;
774- impl_flags ! ( TableClearOptions ) ;
775- impl_flags ! ( TableEqualityOptions ) ;
776- impl_flags ! ( TreeSequenceFlags ) ;
777- impl_flags ! ( TableSortOptions ) ;
778- impl_flags ! ( TreeFlags ) ;
779- impl_flags ! ( IndividualTableSortOptions ) ;
780- impl_flags ! ( TableIntegrityCheckFlags ) ;
781- impl_flags ! ( TableOutputOptions ) ;
782-
783- impl_from_for_flag_types ! ( SimplificationOptions ) ;
784- impl_from_for_flag_types ! ( TableClearOptions ) ;
785- impl_from_for_flag_types ! ( TableEqualityOptions ) ;
786- impl_from_for_flag_types ! ( TreeSequenceFlags ) ;
787- impl_from_for_flag_types ! ( TableSortOptions ) ;
788- impl_from_for_flag_types ! ( TreeFlags ) ;
789- impl_from_for_flag_types ! ( IndividualTableSortOptions ) ;
790- impl_from_for_flag_types ! ( TableIntegrityCheckFlags ) ;
791- impl_from_for_flag_types ! ( TableOutputOptions ) ;
787+ flags_api ! ( SimplificationOptions ) ;
788+ flags_api ! ( TableClearOptions ) ;
789+ flags_api ! ( TableEqualityOptions ) ;
790+ flags_api ! ( TreeSequenceFlags ) ;
791+ flags_api ! ( TableSortOptions ) ;
792+ flags_api ! ( TreeFlags ) ;
793+ flags_api ! ( IndividualTableSortOptions ) ;
794+ flags_api ! ( TableIntegrityCheckFlags ) ;
795+ flags_api ! ( TableOutputOptions ) ;
796+
797+ impl_bit_ops ! ( NodeFlags ) ;
792798
793799impl From < RawFlags > for IndividualFlags {
794800 fn from ( flags : RawFlags ) -> Self {
0 commit comments