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> {
10761076 self . args [ i] . as_usize ( )
10771077 }
10781078 rt:: v1:: Count :: NextParam => {
1079- self . curarg . next ( ) . and_then ( |arg| arg . as_usize ( ) )
1079+ self . curarg . next ( ) ? . as_usize ( )
10801080 }
10811081 }
10821082 }
@@ -1142,15 +1142,15 @@ impl<'a> Formatter<'a> {
11421142 sign = Some ( '+' ) ; width += 1 ;
11431143 }
11441144
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 ( ) ;
11481148 }
11491149
11501150 // Writes the sign if it exists, and then the prefix if it was requested
11511151 let write_prefix = |f : & mut Formatter | {
11521152 if let Some ( c) = sign {
1153- f. buf . write_str ( c . encode_utf8 ( & mut [ 0 ; 4 ] ) ) ?;
1153+ f. buf . write_char ( c ) ?;
11541154 }
11551155 if prefixed { f. buf . write_str ( prefix) }
11561156 else { Ok ( ( ) ) }
@@ -1312,7 +1312,7 @@ impl<'a> Formatter<'a> {
13121312
13131313 // remove the sign from the formatted parts
13141314 formatted. sign = b"" ;
1315- width = if width < sign . len ( ) { 0 } else { width - sign. len ( ) } ;
1315+ width = width. saturating_sub ( sign. len ( ) ) ;
13161316 align = rt:: v1:: Alignment :: Right ;
13171317 self . fill = '0' ;
13181318 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 {
425425 #[ inline]
426426 fn into_searcher ( self , haystack : & ' a str ) -> Self :: Searcher {
427427 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 ( ) ;
430429 CharSearcher {
431430 haystack,
432431 finger : 0 ,
You can’t perform that action at this time.
0 commit comments