@@ -164,14 +164,17 @@ impl<'a, B: UsbBus> UsbDeviceBuilder<'a, B> {
164
164
"Not support more than 16 \" manufacturer\" s"
165
165
) ;
166
166
167
- // do list length check only if user already specify "extra_lang_ids"
168
- let num_extra_langs = self . config . extra_lang_ids . as_ref ( ) . map ( |langs| langs. len ( ) ) . unwrap_or ( 0 ) ;
169
-
167
+ let num_extra_langs = self
168
+ . config
169
+ . extra_lang_ids
170
+ . as_ref ( )
171
+ . map ( |langs| langs. len ( ) )
172
+ . unwrap_or ( 0 ) ;
173
+
170
174
assert ! (
171
175
manufacturer_ls. len( ) == num_extra_langs + 1 ,
172
176
"The length of \" manufacturer\" list should be one more than \" extra_lang_ids\" list" ,
173
- )
174
-
177
+ ) ;
175
178
176
179
self . config . manufacturer = Some ( manufacturer_ls) ;
177
180
@@ -195,13 +198,17 @@ impl<'a, B: UsbBus> UsbDeviceBuilder<'a, B> {
195
198
"Not support more than 16 \" product\" s"
196
199
) ;
197
200
198
- // do list length check only if user already specify "extra_lang_ids"
199
- if let Some ( extra_lang_ids) = self . config . extra_lang_ids {
200
- assert ! (
201
- product_ls. len( ) == extra_lang_ids. len( ) + 1 ,
202
- "The length of \" product\" list should be one more than \" extra_lang_ids\" list" ,
203
- )
204
- }
201
+ let num_extra_langs = self
202
+ . config
203
+ . extra_lang_ids
204
+ . as_ref ( )
205
+ . map ( |langs| langs. len ( ) )
206
+ . unwrap_or ( 0 ) ;
207
+
208
+ assert ! (
209
+ product_ls. len( ) == num_extra_langs + 1 ,
210
+ "The length of \" product\" list should be one more than \" extra_lang_ids\" list" ,
211
+ ) ;
205
212
206
213
self . config . product = Some ( product_ls) ;
207
214
@@ -225,13 +232,17 @@ impl<'a, B: UsbBus> UsbDeviceBuilder<'a, B> {
225
232
"Not support more than 16 \" serial_number\" s"
226
233
) ;
227
234
228
- // do list length check only if user already specify "extra_lang_ids"
229
- if let Some ( extra_lang_ids) = self . config . extra_lang_ids {
230
- assert ! (
231
- serial_number_ls. len( ) == extra_lang_ids. len( ) + 1 ,
232
- "The length of \" serial_number\" list should be one more than \" extra_lang_ids\" list" ,
233
- )
234
- }
235
+ let num_extra_langs = self
236
+ . config
237
+ . extra_lang_ids
238
+ . as_ref ( )
239
+ . map ( |langs| langs. len ( ) )
240
+ . unwrap_or ( 0 ) ;
241
+
242
+ assert ! (
243
+ serial_number_ls. len( ) == num_extra_langs + 1 ,
244
+ "The length of \" serial_number\" list should be one more than \" extra_lang_ids\" list" ,
245
+ ) ;
235
246
236
247
self . config . serial_number = Some ( serial_number_ls) ;
237
248
0 commit comments