@@ -352,8 +352,8 @@ fn type_to_lane_suffixes<'a>(out_t: &'a str, in_t: &'a str, re_to_out: bool) ->
352
352
fn type_to_rot_suffix ( c_name : & str , suf : & str ) -> String {
353
353
let ns: Vec < _ > = c_name. split ( '_' ) . collect ( ) ;
354
354
assert_eq ! ( ns. len( ) , 2 ) ;
355
- if suf. starts_with ( "q" ) {
356
- format ! ( "{}q_{}{}" , ns[ 0 ] , ns[ 1 ] , & suf[ 1 .. ] )
355
+ if let Some ( suf) = suf . strip_prefix ( "q" ) {
356
+ format ! ( "{}q_{}{}" , ns[ 0 ] , ns[ 1 ] , suf)
357
357
} else {
358
358
format ! ( "{c_name}{suf}" )
359
359
}
@@ -3298,18 +3298,18 @@ mod test {
3298
3298
fn_type = Fntype :: Normal ;
3299
3299
separate = false ;
3300
3300
} else if line. starts_with ( "//" ) {
3301
- } else if line. starts_with ( "name = " ) {
3302
- current_name = Some ( String :: from ( & line[ 7 .. ] ) ) ;
3303
- } else if line. starts_with ( "fn = " ) {
3304
- current_fn = Some ( String :: from ( & line[ 5 .. ] ) ) ;
3305
- } else if line. starts_with ( "multi_fn = " ) {
3306
- multi_fn. push ( String :: from ( & line[ 11 .. ] ) ) ;
3307
- } else if line. starts_with ( "constn = " ) {
3308
- constn = Some ( String :: from ( & line[ 9 .. ] ) ) ;
3309
- } else if line. starts_with ( "arm = " ) {
3310
- current_arm = Some ( String :: from ( & line[ 6 .. ] ) ) ;
3311
- } else if line. starts_with ( "aarch64 = " ) {
3312
- current_aarch64 = Some ( String :: from ( & line[ 10 .. ] ) ) ;
3301
+ } else if let Some ( line) = line . strip_prefix ( "name = " ) {
3302
+ current_name = Some ( String :: from ( line) ) ;
3303
+ } else if let Some ( line) = line . strip_prefix ( "fn = " ) {
3304
+ current_fn = Some ( String :: from ( line) ) ;
3305
+ } else if let Some ( line) = line . strip_prefix ( "multi_fn = " ) {
3306
+ multi_fn. push ( String :: from ( line) ) ;
3307
+ } else if let Some ( line) = line . strip_prefix ( "constn = " ) {
3308
+ constn = Some ( String :: from ( line) ) ;
3309
+ } else if let Some ( line) = line . strip_prefix ( "arm = " ) {
3310
+ current_arm = Some ( String :: from ( line) ) ;
3311
+ } else if let Some ( line) = line . strip_prefix ( "aarch64 = " ) {
3312
+ current_aarch64 = Some ( String :: from ( line) ) ;
3313
3313
} else if line. starts_with ( "double-suffixes" ) {
3314
3314
suffix = Double ;
3315
3315
} else if line. starts_with ( "no-q" ) {
@@ -3348,35 +3348,35 @@ mod test {
3348
3348
suffix = Rot ;
3349
3349
} else if line. starts_with ( "rot-lane-suffixes" ) {
3350
3350
suffix = RotLane ;
3351
- } else if line. starts_with ( "a = " ) {
3352
- a = line[ 4 .. ] . split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3353
- } else if line. starts_with ( "b = " ) {
3354
- b = line[ 4 .. ] . split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3355
- } else if line. starts_with ( "c = " ) {
3356
- c = line[ 4 .. ] . split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3357
- } else if line. starts_with ( "n = " ) {
3358
- n = Some ( String :: from ( & line[ 4 .. ] ) ) ;
3359
- } else if line. starts_with ( "fixed = " ) {
3360
- fixed = line[ 8 .. ] . split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3361
- } else if line. starts_with ( "validate " ) {
3362
- let e = line[ 9 .. ] . split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3351
+ } else if let Some ( line) = line . strip_prefix ( "a = " ) {
3352
+ a = line. split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3353
+ } else if let Some ( line) = line . strip_prefix ( "b = " ) {
3354
+ b = line. split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3355
+ } else if let Some ( line) = line . strip_prefix ( "c = " ) {
3356
+ c = line. split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3357
+ } else if let Some ( line) = line . strip_prefix ( "n = " ) {
3358
+ n = Some ( String :: from ( line) ) ;
3359
+ } else if let Some ( line) = line . strip_prefix ( "fixed = " ) {
3360
+ fixed = line. split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3361
+ } else if let Some ( line) = line . strip_prefix ( "validate " ) {
3362
+ let e = line. split ( ',' ) . map ( |v| v. trim ( ) . to_string ( ) ) . collect ( ) ;
3363
3363
current_tests. push ( ( a. clone ( ) , b. clone ( ) , c. clone ( ) , n. clone ( ) , e) ) ;
3364
- } else if line. starts_with ( "link-aarch64 = " ) {
3365
- link_aarch64 = Some ( String :: from ( & line[ 15 .. ] ) ) ;
3366
- } else if line. starts_with ( "const-aarch64 = " ) {
3367
- const_aarch64 = Some ( String :: from ( & line[ 16 .. ] ) ) ;
3368
- } else if line. starts_with ( "link-arm = " ) {
3369
- link_arm = Some ( String :: from ( & line[ 11 .. ] ) ) ;
3370
- } else if line. starts_with ( "const-arm = " ) {
3371
- const_arm = Some ( String :: from ( & line[ 12 .. ] ) ) ;
3364
+ } else if let Some ( line) = line . strip_prefix ( "link-aarch64 = " ) {
3365
+ link_aarch64 = Some ( String :: from ( line) ) ;
3366
+ } else if let Some ( line) = line . strip_prefix ( "const-aarch64 = " ) {
3367
+ const_aarch64 = Some ( String :: from ( line) ) ;
3368
+ } else if let Some ( line) = line . strip_prefix ( "link-arm = " ) {
3369
+ link_arm = Some ( String :: from ( line) ) ;
3370
+ } else if let Some ( line) = line . strip_prefix ( "const-arm = " ) {
3371
+ const_arm = Some ( String :: from ( line) ) ;
3372
3372
} else if line. starts_with ( "load_fn" ) {
3373
3373
fn_type = Fntype :: Load ;
3374
3374
} else if line. starts_with ( "store_fn" ) {
3375
3375
fn_type = Fntype :: Store ;
3376
3376
} else if line. starts_with ( "arm-aarch64-separate" ) {
3377
3377
separate = true ;
3378
- } else if line. starts_with ( "target = " ) {
3379
- target = match Some ( String :: from ( & line[ 9 .. ] ) ) {
3378
+ } else if let Some ( line) = line . strip_prefix ( "target = " ) {
3379
+ target = match Some ( String :: from ( line) ) {
3380
3380
Some ( input) => match input. as_str ( ) {
3381
3381
"v7" => ArmV7 ,
3382
3382
"vfp4" => Vfp4 ,
@@ -3393,8 +3393,7 @@ mod test {
3393
3393
} ,
3394
3394
_ => Default ,
3395
3395
}
3396
- } else if line. starts_with ( "generate " ) {
3397
- let line = & line[ 9 ..] ;
3396
+ } else if let Some ( line) = line. strip_prefix ( "generate " ) {
3398
3397
let types: Vec < String > = line
3399
3398
. split ( ',' )
3400
3399
. map ( |v| v. trim ( ) . to_string ( ) )
0 commit comments