@@ -5,17 +5,9 @@ use super::bindings::tsk_flags_t;
55
66use std:: ops:: BitXorAssign ;
77
8- trait TstkitFlags {
9- fn raw ( & self ) -> RawFlags ;
10- fn raw_mut ( & mut self ) -> & mut RawFlags ;
11- }
12-
13- impl TstkitFlags for NodeFlags {
14- fn raw ( & self ) -> RawFlags {
15- self . 0
16- }
17- fn raw_mut ( & mut self ) -> & mut RawFlags {
18- & mut self . 0
8+ macro_rules! make_constant_self {
9+ ( $name: ident, $constant: ident) => {
10+ pub const $name: Self = Self ( ll_bindings:: $constant) ;
1911 }
2012}
2113
@@ -77,10 +69,14 @@ macro_rules! contains {
7769 } ;
7870}
7971
80- impl std:: ops:: BitXorAssign for NodeFlags {
81- fn bitxor_assign ( & mut self , rhs : Self ) {
82- self . 0 ^= rhs. 0
83- }
72+ macro_rules! impl_bit_ops {
73+ ( $type: ty) => {
74+ impl std:: ops:: BitXorAssign for $type {
75+ fn bitxor_assign( & mut self , rhs: Self ) {
76+ self . 0 ^= rhs. 0
77+ }
78+ }
79+ } ;
8480}
8581
8682/// Control the behavior of table simplification.
@@ -682,7 +678,7 @@ impl NodeFlags {
682678 /// Default (empty)
683679 pub const NONE : Self = Self ( 0 ) ;
684680 /// Node is a sample
685- pub const IS_SAMPLE : Self = Self ( ll_bindings :: TSK_NODE_IS_SAMPLE ) ;
681+ make_constant_self ! ( IS_SAMPLE , TSK_NODE_IS_SAMPLE ) ;
686682
687683 /// Create a new flags instance with `IS_SAMPLE` set.
688684 pub fn new_sample ( ) -> Self {
@@ -734,6 +730,8 @@ impl From<tsk_flags_t> for NodeFlags {
734730 }
735731}
736732
733+ impl_bit_ops ! ( NodeFlags ) ;
734+
737735#[ derive( Default , Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
738736#[ repr( transparent) ]
739737/// Individual flags
0 commit comments