@@ -347,16 +347,11 @@ impl<'a> Lexer<'a> {
347347 }
348348
349349 fn next_char_if_eq ( & mut self , expect : char ) -> bool {
350- self . next_char_if ( |c| c == expect) != None
350+ self . next_char_if ( |c| c == expect) . is_some ( )
351351 }
352352
353353 fn next_char_if_in ( & mut self , alphabet : & str ) -> Option < char > {
354- for c in alphabet. chars ( ) {
355- if self . next_char_if_eq ( c) {
356- return Some ( c) ;
357- }
358- }
359- None
354+ alphabet. chars ( ) . find ( |& c| self . next_char_if_eq ( c) )
360355 }
361356
362357 fn next_char_expect_eq ( & mut self , expect : char ) -> ParserResult < ( ) > {
@@ -430,7 +425,7 @@ impl<'a> Lexer<'a> {
430425 Ok (
431426 if self . skip_if_lookahead_is_str ( "0x" ) || self . skip_if_lookahead_is_str ( "0X" ) {
432427 let s = self . take_while ( Lexer :: is_ascii_hexdigit) ;
433- Some ( u64:: from_str_radix ( s, 16 ) ? as u64 )
428+ Some ( u64:: from_str_radix ( s, 16 ) ?)
434429 } else {
435430 None
436431 } ,
@@ -449,7 +444,7 @@ impl<'a> Lexer<'a> {
449444
450445 let pos = clone. pos ;
451446
452- Ok ( if clone. next_char_if ( Lexer :: is_ascii_digit) != None {
447+ Ok ( if clone. next_char_if ( Lexer :: is_ascii_digit) . is_some ( ) {
453448 clone. take_while ( Lexer :: is_ascii_digit) ;
454449 let value = clone. input [ pos..clone. pos ] . parse ( ) ?;
455450 * self = clone;
@@ -517,7 +512,7 @@ impl<'a> Lexer<'a> {
517512
518513 // exponent = ( "e" | "E" ) [ "+" | "-" ] decimals
519514 fn next_exponent_opt ( & mut self ) -> ParserResult < Option < ( ) > > {
520- if self . next_char_if_in ( "eE" ) != None {
515+ if self . next_char_if_in ( "eE" ) . is_some ( ) {
521516 self . next_char_if_in ( "+-" ) ;
522517 self . next_decimal_digits ( ) ?;
523518 Ok ( Some ( ( ) ) )
@@ -537,7 +532,7 @@ impl<'a> Lexer<'a> {
537532 if self . next_char_if_eq ( '.' ) {
538533 self . next_decimal_digits ( ) ?;
539534 self . next_exponent_opt ( ) ?;
540- } else if self . next_exponent_opt ( ) ? == None {
535+ } else if ( self . next_exponent_opt ( ) ?) . is_none ( ) {
541536 return Err ( ParserError :: IncorrectFloatLit ) ;
542537 }
543538 }
@@ -931,7 +926,7 @@ impl<'a> Parser<'a> {
931926 }
932927
933928 fn next_ident_if_eq ( & mut self , word : & str ) -> ParserResult < bool > {
934- Ok ( self . next_ident_if_in ( & [ word] ) ? != None )
929+ Ok ( ( self . next_ident_if_in ( & [ word] ) ?) . is_some ( ) )
935930 }
936931
937932 pub fn next_ident_expect_eq ( & mut self , word : & str ) -> ParserResult < ( ) > {
@@ -950,7 +945,10 @@ impl<'a> Parser<'a> {
950945 }
951946
952947 fn next_symbol_if_eq ( & mut self , symbol : char ) -> ParserResult < bool > {
953- Ok ( self . next_token_if ( |token| matches ! ( * token, Token :: Symbol ( c) if c == symbol) ) ? != None )
948+ Ok (
949+ ( self . next_token_if ( |token| matches ! ( * token, Token :: Symbol ( c) if c == symbol) ) ?)
950+ . is_some ( ) ,
951+ )
954952 }
955953
956954 fn next_symbol_expect_eq ( & mut self , symbol : char ) -> ParserResult < ( ) > {
0 commit comments