File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -1076,7 +1076,7 @@ impl<'a> Formatter<'a> {
1076
1076
self . args [ i] . as_usize ( )
1077
1077
}
1078
1078
rt:: v1:: Count :: NextParam => {
1079
- self . curarg . next ( ) . and_then ( |arg| arg . as_usize ( ) )
1079
+ self . curarg . next ( ) ? . as_usize ( )
1080
1080
}
1081
1081
}
1082
1082
}
@@ -1142,15 +1142,15 @@ impl<'a> Formatter<'a> {
1142
1142
sign = Some ( '+' ) ; width += 1 ;
1143
1143
}
1144
1144
1145
- let mut prefixed = false ;
1146
- if self . alternate ( ) {
1147
- prefixed = true ; width += prefix. chars ( ) . count ( ) ;
1145
+ let prefixed = self . alternate ( ) ;
1146
+ if prefixed {
1147
+ width += prefix. chars ( ) . count ( ) ;
1148
1148
}
1149
1149
1150
1150
// Writes the sign if it exists, and then the prefix if it was requested
1151
1151
let write_prefix = |f : & mut Formatter | {
1152
1152
if let Some ( c) = sign {
1153
- f. buf . write_str ( c . encode_utf8 ( & mut [ 0 ; 4 ] ) ) ?;
1153
+ f. buf . write_char ( c ) ?;
1154
1154
}
1155
1155
if prefixed { f. buf . write_str ( prefix) }
1156
1156
else { Ok ( ( ) ) }
@@ -1312,7 +1312,7 @@ impl<'a> Formatter<'a> {
1312
1312
1313
1313
// remove the sign from the formatted parts
1314
1314
formatted. sign = b"" ;
1315
- width = if width < sign . len ( ) { 0 } else { width - sign. len ( ) } ;
1315
+ width = width. saturating_sub ( sign. len ( ) ) ;
1316
1316
align = rt:: v1:: Alignment :: Right ;
1317
1317
self . fill = '0' ;
1318
1318
self . align = rt:: v1:: Alignment :: Right ;
Original file line number Diff line number Diff line change @@ -425,8 +425,7 @@ impl<'a> Pattern<'a> for char {
425
425
#[ inline]
426
426
fn into_searcher ( self , haystack : & ' a str ) -> Self :: Searcher {
427
427
let mut utf8_encoded = [ 0 ; 4 ] ;
428
- self . encode_utf8 ( & mut utf8_encoded) ;
429
- let utf8_size = self . len_utf8 ( ) ;
428
+ let utf8_size = self . encode_utf8 ( & mut utf8_encoded) . len ( ) ;
430
429
CharSearcher {
431
430
haystack,
432
431
finger : 0 ,
You can’t perform that action at this time.
0 commit comments