File tree Expand file tree Collapse file tree 1 file changed +42
-5
lines changed Expand file tree Collapse file tree 1 file changed +42
-5
lines changed Original file line number Diff line number Diff line change @@ -856,6 +856,23 @@ pub fn fields(
856856 } ,
857857 ) ;
858858 }
859+
860+ if f. width == 1 {
861+ enum_items. push ( quote ! {
862+ /// Returns `true` if the bit is clear (0)
863+ #[ inline( always) ]
864+ pub fn is_clear( & self ) -> bool {
865+ !self . #bits( )
866+ }
867+
868+ /// Returns `true` if the bit is set (1)
869+ #[ inline( always) ]
870+ pub fn is_set( & self ) -> bool {
871+ self . #bits( )
872+ }
873+ } ) ;
874+ }
875+
859876 enum_items. push (
860877 quote ! {
861878 /// Value of the field as raw bits
@@ -957,6 +974,30 @@ pub fn fields(
957974 } ,
958975 ) ;
959976
977+ let mut pc_r_impl_items = vec ! [ quote! {
978+ /// Value of the field as raw bits
979+ #[ inline( always) ]
980+ pub fn #bits( & self ) -> #fty {
981+ self . bits
982+ }
983+ } ] ;
984+
985+ if f. width == 1 {
986+ pc_r_impl_items. push ( quote ! {
987+ /// Returns `true` if the bit is clear (0)
988+ #[ inline( always) ]
989+ pub fn is_clear( & self ) -> bool {
990+ !self . #bits( )
991+ }
992+
993+ /// Returns `true` if the bit is set (1)
994+ #[ inline( always) ]
995+ pub fn is_set( & self ) -> bool {
996+ self . #bits( )
997+ }
998+ } ) ;
999+ }
1000+
9601001 mod_items. push (
9611002 quote ! {
9621003 /// Value of the field
@@ -965,11 +1006,7 @@ pub fn fields(
9651006 }
9661007
9671008 impl #pc_r {
968- /// Value of the field as raw bits
969- #[ inline( always) ]
970- pub fn #bits( & self ) -> #fty {
971- self . bits
972- }
1009+ #( #pc_r_impl_items) *
9731010 }
9741011 } ,
9751012 ) ;
You can’t perform that action at this time.
0 commit comments