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(
856
856
} ,
857
857
) ;
858
858
}
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
+
859
876
enum_items. push (
860
877
quote ! {
861
878
/// Value of the field as raw bits
@@ -957,6 +974,30 @@ pub fn fields(
957
974
} ,
958
975
) ;
959
976
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
+
960
1001
mod_items. push (
961
1002
quote ! {
962
1003
/// Value of the field
@@ -965,11 +1006,7 @@ pub fn fields(
965
1006
}
966
1007
967
1008
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) *
973
1010
}
974
1011
} ,
975
1012
) ;
You can’t perform that action at this time.
0 commit comments