@@ -659,21 +659,34 @@ pub fn fields(
659
659
Ident :: new ( "FieldWriterSafe" , span)
660
660
} ;
661
661
662
+ let ( offset, gen_offset) = if field_dim. is_some ( ) {
663
+ ( quote ! { O } , quote ! { , const O : u8 } )
664
+ } else {
665
+ ( util:: unsuffixed ( offset as u64 ) , quote ! { } )
666
+ } ;
662
667
let proxy = if width == 1 {
663
- quote ! { crate :: BitWriter <' a, #rty, #name_uc_spec, #name_pc_aw, O > }
668
+ quote ! { crate :: BitWriter <' a, #rty, #name_uc_spec, #name_pc_aw, #offset > }
664
669
} else {
665
670
let width = & util:: unsuffixed ( width as _ ) ;
666
- quote ! { crate :: #wproxy<' a, #rty, #name_uc_spec, #fty, #name_pc_aw, #width, O > }
671
+ quote ! { crate :: #wproxy<' a, #rty, #name_uc_spec, #fty, #name_pc_aw, #width, #offset > }
667
672
} ;
668
673
mod_items. extend ( quote ! {
669
674
#[ doc = #writerdoc]
670
- pub type #name_pc_w<' a, const O : u8 > = #proxy;
675
+ pub type #name_pc_w<' a #gen_offset > = #proxy;
671
676
} ) ;
672
677
}
673
678
if !proxy_items. is_empty ( ) {
674
- mod_items. extend ( quote ! {
675
- impl <' a, const O : u8 > #name_pc_w<' a, O > {
676
- #proxy_items
679
+ mod_items. extend ( if field_dim. is_some ( ) {
680
+ quote ! {
681
+ impl <' a, const O : u8 > #name_pc_w<' a, O > {
682
+ #proxy_items
683
+ }
684
+ }
685
+ } else {
686
+ quote ! {
687
+ impl <' a> #name_pc_w<' a> {
688
+ #proxy_items
689
+ }
677
690
}
678
691
} ) ;
679
692
}
@@ -710,11 +723,10 @@ pub fn fields(
710
723
}
711
724
} else {
712
725
let doc = description_with_bits ( description_raw, offset, width) ;
713
- let offset = util:: unsuffixed ( offset as u64 ) ;
714
726
w_impl_items. extend ( quote ! {
715
727
#[ doc = #doc]
716
728
#inline
717
- pub fn #name_sc( & mut self ) -> #name_pc_w<#offset> {
729
+ pub fn #name_sc( & mut self ) -> #name_pc_w {
718
730
#name_pc_w:: new( self )
719
731
}
720
732
} ) ;
0 commit comments