@@ -582,34 +582,38 @@ impl Cursor<'_> {
582
582
let mut base = Base :: Decimal ;
583
583
if first_digit == '0' {
584
584
// Attempt to parse encoding base.
585
- let has_digits = match self . first ( ) {
585
+ match self . first ( ) {
586
586
'b' => {
587
587
base = Base :: Binary ;
588
588
self . bump ( ) ;
589
- self . eat_decimal_digits ( )
589
+ if !self . eat_decimal_digits ( ) {
590
+ return Int { base, empty_int : true } ;
591
+ }
590
592
}
591
593
'o' => {
592
594
base = Base :: Octal ;
593
595
self . bump ( ) ;
594
- self . eat_decimal_digits ( )
596
+ if !self . eat_decimal_digits ( ) {
597
+ return Int { base, empty_int : true } ;
598
+ }
595
599
}
596
600
'x' => {
597
601
base = Base :: Hexadecimal ;
598
602
self . bump ( ) ;
599
- self . eat_hexadecimal_digits ( )
603
+ if !self . eat_hexadecimal_digits ( ) {
604
+ return Int { base, empty_int : true } ;
605
+ }
600
606
}
601
- // Not a base prefix.
602
- '0' ..='9' | '_' | '.' | 'e' | 'E' => {
607
+ // Not a base prefix; consume additional digits .
608
+ '0' ..='9' | '_' => {
603
609
self . eat_decimal_digits ( ) ;
604
- true
605
610
}
611
+
612
+ // Also not a base prefix; nothing more to do here.
613
+ '.' | 'e' | 'E' => { }
614
+
606
615
// Just a 0.
607
616
_ => 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 } ;
613
617
}
614
618
} else {
615
619
// No base prefix, parse number in the usual way.
0 commit comments