@@ -582,34 +582,38 @@ impl Cursor<'_> {
582582 let mut base = Base :: Decimal ;
583583 if first_digit == '0' {
584584 // Attempt to parse encoding base.
585- let has_digits = match self . first ( ) {
585+ match self . first ( ) {
586586 'b' => {
587587 base = Base :: Binary ;
588588 self . bump ( ) ;
589- self . eat_decimal_digits ( )
589+ if !self . eat_decimal_digits ( ) {
590+ return Int { base, empty_int : true } ;
591+ }
590592 }
591593 'o' => {
592594 base = Base :: Octal ;
593595 self . bump ( ) ;
594- self . eat_decimal_digits ( )
596+ if !self . eat_decimal_digits ( ) {
597+ return Int { base, empty_int : true } ;
598+ }
595599 }
596600 'x' => {
597601 base = Base :: Hexadecimal ;
598602 self . bump ( ) ;
599- self . eat_hexadecimal_digits ( )
603+ if !self . eat_hexadecimal_digits ( ) {
604+ return Int { base, empty_int : true } ;
605+ }
600606 }
601- // Not a base prefix.
602- '0' ..='9' | '_' | '.' | 'e' | 'E' => {
607+ // Not a base prefix; consume additional digits .
608+ '0' ..='9' | '_' => {
603609 self . eat_decimal_digits ( ) ;
604- true
605610 }
611+
612+ // Also not a base prefix; nothing more to do here.
613+ '.' | 'e' | 'E' => { }
614+
606615 // Just a 0.
607616 _ => return Int { base, empty_int : false } ,
608- } ;
609- // Base prefix was provided, but there were no digits
610- // after it, e.g. "0x".
611- if !has_digits {
612- return Int { base, empty_int : true } ;
613617 }
614618 } else {
615619 // No base prefix, parse number in the usual way.
0 commit comments