@@ -19,11 +19,15 @@ pub fn gen_peripheral(p: &Peripheral, d: &Defaults) -> Vec<Tokens> {
1919 let mut fields = vec ! [ ] ;
2020 let mut offset = 0 ;
2121 let mut i = 0 ;
22- let registers = p. registers . as_ref ( ) . expect ( & format ! ( "{:#?} has no `registers` field" , p) ) ;
22+ let registers = p. registers
23+ . as_ref ( )
24+ . expect ( & format ! ( "{:#?} has no `registers` field" , p) ) ;
2325 for register in registers {
2426 let pad = register. address_offset
2527 . checked_sub ( offset)
26- . unwrap_or_else ( || panic ! ( "{:#?} overlapped with other register!" , p) ) ;
28+ . unwrap_or_else ( || {
29+ panic ! ( "{:#?} overlapped with other register!" , p)
30+ } ) ;
2731
2832 if pad != 0 {
2933 let name = Ident :: new ( format ! ( "_reserved{}" , i) ) ;
@@ -34,9 +38,10 @@ pub fn gen_peripheral(p: &Peripheral, d: &Defaults) -> Vec<Tokens> {
3438 i += 1 ;
3539 }
3640
37- let comment = & format ! ( "0x{:02x} - {}" ,
38- register. address_offset,
39- respace( & register. description) ) [ ..] ;
41+ let comment =
42+ & format ! ( "0x{:02x} - {}" ,
43+ register. address_offset,
44+ respace( & register. description) ) [ ..] ;
4045
4146 let field_ty = Ident :: new ( register. name . to_pascal_case ( ) ) ;
4247 let field_name = Ident :: new ( register. name . to_snake_case ( ) ) ;
@@ -46,7 +51,9 @@ pub fn gen_peripheral(p: &Peripheral, d: &Defaults) -> Vec<Tokens> {
4651 } ) ;
4752
4853 offset = register. address_offset +
49- register. size . or ( d. size ) . expect ( & format ! ( "{:#?} has no `size` field" , register) ) /
54+ register. size
55+ . or ( d. size )
56+ . expect ( & format ! ( "{:#?} has no `size` field" , register) ) /
5057 8 ;
5158 }
5259
@@ -81,9 +88,14 @@ pub fn gen_register(r: &Register, d: &Defaults) -> Vec<Tokens> {
8188 let mut items = vec ! [ ] ;
8289
8390 let name = Ident :: new ( r. name . to_pascal_case ( ) ) ;
84- let bits_ty = r. size . or ( d. size ) . expect ( & format ! ( "{:#?} has no `size` field" , r) ) . to_ty ( ) ;
91+ let bits_ty = r. size
92+ . or ( d. size )
93+ . expect ( & format ! ( "{:#?} has no `size` field" , r) )
94+ . to_ty ( ) ;
8595 let access = r. access . unwrap_or_else ( || {
86- let fields = r. fields . as_ref ( ) . expect ( & format ! ( "{:#?} has no `fields` field" , r) ) ;
96+ let fields = r. fields
97+ . as_ref ( )
98+ . expect ( & format ! ( "{:#?} has no `fields` field" , r) ) ;
8799 if fields. iter ( ) . all ( |f| f. access == Some ( Access :: ReadOnly ) ) {
88100 Access :: ReadOnly
89101 } else if fields. iter ( ) . all ( |f| f. access == Some ( Access :: WriteOnly ) ) {
@@ -182,7 +194,10 @@ pub fn gen_register_r(r: &Register, d: &Defaults) -> Vec<Tokens> {
182194 let mut items = vec ! [ ] ;
183195
184196 let name = Ident :: new ( format ! ( "{}R" , r. name. to_pascal_case( ) ) ) ;
185- let bits_ty = r. size . or ( d. size ) . expect ( & format ! ( "{:#?} has no `size` field" , r) ) . to_ty ( ) ;
197+ let bits_ty = r. size
198+ . or ( d. size )
199+ . expect ( & format ! ( "{:#?} has no `size` field" , r) )
200+ . to_ty ( ) ;
186201
187202 items. push ( quote ! {
188203 #[ derive( Clone , Copy ) ]
@@ -193,7 +208,9 @@ pub fn gen_register_r(r: &Register, d: &Defaults) -> Vec<Tokens> {
193208
194209 let mut impl_items = vec ! [ ] ;
195210
196- for field in r. fields . as_ref ( ) . expect ( & format ! ( "{:#?} has no `fields` field" , r) ) {
211+ for field in r. fields
212+ . as_ref ( )
213+ . expect ( & format ! ( "{:#?} has no `fields` field" , r) ) {
197214 if let Some ( Access :: WriteOnly ) = field. access {
198215 continue ;
199216 }
@@ -257,7 +274,10 @@ pub fn gen_register_w(r: &Register, d: &Defaults) -> Vec<Tokens> {
257274 let mut items = vec ! [ ] ;
258275
259276 let name = Ident :: new ( format ! ( "{}W" , r. name. to_pascal_case( ) ) ) ;
260- let bits_ty = r. size . or ( d. size ) . expect ( & format ! ( "{:#?} has no `size` field" , r) ) . to_ty ( ) ;
277+ let bits_ty = r. size
278+ . or ( d. size )
279+ . expect ( & format ! ( "{:#?} has no `size` field" , r) )
280+ . to_ty ( ) ;
261281 items. push ( quote ! {
262282 #[ derive( Clone , Copy ) ]
263283 #[ repr( C ) ]
@@ -277,7 +297,9 @@ pub fn gen_register_w(r: &Register, d: &Defaults) -> Vec<Tokens> {
277297 } ) ;
278298 }
279299
280- for field in r. fields . as_ref ( ) . expect ( & format ! ( "{:#?} has no `fields` field" , r) ) {
300+ for field in r. fields
301+ . as_ref ( )
302+ . expect ( & format ! ( "{:#?} has no `fields` field" , r) ) {
281303 if let Some ( Access :: ReadOnly ) = field. access {
282304 continue ;
283305 }
0 commit comments