@@ -66,7 +66,7 @@ impl DeviceExt for Device {
66
66
// Handle any deletions
67
67
for pspec in device. str_vec_iter ( "_delete" ) {
68
68
self . delete_peripheral ( pspec)
69
- . with_context ( || format ! ( "Deleting peripheral matched to `{}`" , pspec ) ) ?;
69
+ . with_context ( || format ! ( "Deleting peripheral matched to `{pspec }`" ) ) ?;
70
70
}
71
71
72
72
// Handle any copied peripherals
@@ -77,7 +77,7 @@ impl DeviceExt for Device {
77
77
val. hash ( ) ?,
78
78
Path :: new ( device. get_str ( "_path" ) ?. unwrap_or ( "." ) ) ,
79
79
)
80
- . with_context ( || format ! ( "Copying peripheral `{}`" , pname ) ) ?;
80
+ . with_context ( || format ! ( "Copying peripheral `{pname }`" ) ) ?;
81
81
}
82
82
83
83
// Handle any modifications
@@ -92,7 +92,7 @@ impl DeviceExt for Device {
92
92
let pspec = pspec. str ( ) ?;
93
93
self . modify_peripheral ( pspec, pmod. hash ( ) ?)
94
94
. with_context ( || {
95
- format ! ( "Modifying peripherals matched to `{}`" , pspec )
95
+ format ! ( "Modifying peripherals matched to `{pspec }`" )
96
96
} ) ?;
97
97
}
98
98
}
@@ -115,40 +115,37 @@ impl DeviceExt for Device {
115
115
116
116
_ => self
117
117
. modify_peripheral ( key, val. hash ( ) ?)
118
- . with_context ( || format ! ( "Modifying peripherals matched to `{}`" , key ) ) ?,
118
+ . with_context ( || format ! ( "Modifying peripherals matched to `{key }`" ) ) ?,
119
119
}
120
120
}
121
121
122
122
// Handle field clearing
123
123
for pspec in device. str_vec_iter ( "_clear_fields" ) {
124
124
self . clear_fields ( pspec) . with_context ( || {
125
- format ! (
126
- "Clearing contents of fields in peripherals matched to `{}` " ,
127
- pspec
128
- )
125
+ format ! ( "Clearing contents of fields in peripherals matched to `{pspec}` " )
129
126
} ) ?;
130
127
}
131
128
132
129
// Handle any new peripherals (!)
133
130
for ( pname, padd) in device. hash_iter ( "_add" ) {
134
131
let pname = pname. str ( ) ?;
135
132
self . add_peripheral ( pname, padd. hash ( ) ?)
136
- . with_context ( || format ! ( "Adding peripheral `{}`" , pname ) ) ?;
133
+ . with_context ( || format ! ( "Adding peripheral `{pname }`" ) ) ?;
137
134
}
138
135
139
136
// Handle any derived peripherals
140
137
for ( pname, pderive) in device. hash_iter ( "_derive" ) {
141
138
let pname = pname. str ( ) ?;
142
139
self . derive_peripheral ( pname, pderive)
143
- . with_context ( || format ! ( "Deriving peripheral `{}` from `{:?}`" , pname , pderive ) ) ?;
140
+ . with_context ( || format ! ( "Deriving peripheral `{pname }` from `{pderive :?}`" ) ) ?;
144
141
}
145
142
146
143
// Handle any rebased peripherals
147
144
for ( pname, pold) in device. hash_iter ( "_rebase" ) {
148
145
let pname = pname. str ( ) ?;
149
146
let pold = pold. str ( ) ?;
150
147
self . rebase_peripheral ( pname, pold)
151
- . with_context ( || format ! ( "Rebasing peripheral from `{}` to `{}`" , pold , pname ) ) ?;
148
+ . with_context ( || format ! ( "Rebasing peripheral from `{pold }` to `{pname }`" ) ) ?;
152
149
}
153
150
154
151
// Now process all peripherals
@@ -157,7 +154,7 @@ impl DeviceExt for Device {
157
154
if !periphspec. starts_with ( '_' ) {
158
155
//val["_path"] = device["_path"]; // TODO: check
159
156
self . process_peripheral ( periphspec, val. hash ( ) ?, update_fields)
160
- . with_context ( || format ! ( "According to `{}`" , periphspec ) ) ?;
157
+ . with_context ( || format ! ( "According to `{periphspec }`" ) ) ?;
161
158
}
162
159
}
163
160
@@ -181,16 +178,16 @@ impl DeviceExt for Device {
181
178
let mut contents = String :: new ( ) ;
182
179
( & f) . read_to_string ( & mut contents) . unwrap ( ) ;
183
180
let filedev = svd_parser:: parse ( & contents)
184
- . with_context ( || format ! ( "Parsing file {}" , contents ) ) ?;
181
+ . with_context ( || format ! ( "Parsing file {contents}" ) ) ?;
185
182
filedev
186
183
. get_peripheral ( pcopyname)
187
- . ok_or_else ( || anyhow ! ( "peripheral {} not found" , pcopyname ) ) ?
184
+ . ok_or_else ( || anyhow ! ( "peripheral {pcopyname } not found" ) ) ?
188
185
. clone ( )
189
186
}
190
187
[ pcopyname] => {
191
188
let mut new = self
192
189
. get_peripheral ( pcopyname)
193
- . ok_or_else ( || anyhow ! ( "peripheral {} not found" , pcopyname ) ) ?
190
+ . ok_or_else ( || anyhow ! ( "peripheral {pcopyname } not found" ) ) ?
194
191
. clone ( ) ;
195
192
// When copying from a peripheral in the same file, remove any interrupts.
196
193
new. interrupt = Vec :: new ( ) ;
@@ -265,7 +262,7 @@ impl DeviceExt for Device {
265
262
266
263
fn add_peripheral ( & mut self , pname : & str , padd : & Hash ) -> PatchResult {
267
264
if self . get_peripheral ( pname) . is_some ( ) {
268
- return Err ( anyhow ! ( "device already has a peripheral {}" , pname ) ) ;
265
+ return Err ( anyhow ! ( "device already has a peripheral {pname}" ) ) ;
269
266
}
270
267
271
268
self . peripherals . push (
@@ -300,7 +297,7 @@ impl DeviceExt for Device {
300
297
301
298
if !pderive. contains ( '.' ) {
302
299
self . get_peripheral ( pderive)
303
- . ok_or_else ( || anyhow ! ( "peripheral {} not found" , pderive ) ) ?;
300
+ . ok_or_else ( || anyhow ! ( "peripheral {pderive } not found" ) ) ?;
304
301
}
305
302
306
303
match self . get_mut_peripheral ( pname) {
@@ -324,7 +321,7 @@ impl DeviceExt for Device {
324
321
fn rebase_peripheral ( & mut self , pnew : & str , pold : & str ) -> PatchResult {
325
322
let old = self
326
323
. get_mut_peripheral ( pold)
327
- . ok_or_else ( || anyhow ! ( "peripheral {} not found" , pold ) ) ?;
324
+ . ok_or_else ( || anyhow ! ( "peripheral {pold } not found" ) ) ?;
328
325
let mut d = std:: mem:: replace (
329
326
old,
330
327
PeripheralInfo :: builder ( )
@@ -341,7 +338,7 @@ impl DeviceExt for Device {
341
338
) ;
342
339
let new = self
343
340
. get_mut_peripheral ( pnew)
344
- . ok_or_else ( || anyhow ! ( "peripheral {} not found" , pnew ) ) ?;
341
+ . ok_or_else ( || anyhow ! ( "peripheral {pnew } not found" ) ) ?;
345
342
d. name = new. name . clone ( ) ;
346
343
d. base_address = new. base_address ;
347
344
d. interrupt = new. interrupt . clone ( ) ;
@@ -380,7 +377,7 @@ impl DeviceExt for Device {
380
377
. with_context ( || format ! ( "Processing peripheral `{}`" , ptag. name) ) ?;
381
378
}
382
379
if pcount == 0 {
383
- Err ( anyhow ! ( "Could not find `{}`" , pspec ) )
380
+ Err ( anyhow ! ( "Could not find `{pspec }`" ) )
384
381
} else {
385
382
Ok ( ( ) )
386
383
}
0 commit comments