Description
Setting the format API to use internal digit separators doesn't work correctly on hex numbers, if those the options for it were created from another set of options.
Prerequisites
- Rust version: rustc 1.97.1 (8bab26f4f 2026-07-14)
- lexical version: 7.0.5
- lexical compilation features used: format, power-of-two
Test case
Example test case:
use core::num::NonZeroU8;
use lexical::{NumberFormat, NumberFormatBuilder, ParseIntegerOptions, parse_with_options};
const BASE: u128 = NumberFormatBuilder::new()
.digit_separator(NonZeroU8::new(b'_'))
.internal_digit_separator(true)
.case_sensitive_base_prefix(true)
.build_strict();
const HEX: u128 = NumberFormat::<BASE>::builder()
.base_prefix(NonZeroU8::new(b'x'))
.radix(16)
.build_strict();
const HEX_OPTIONS: ParseIntegerOptions = ParseIntegerOptions::from_radix(16);
fn main() {
println!(
"{:?}",
parse_with_options::<i128, _, HEX>("0x1234_5678", &HEX_OPTIONS)
);
}
This will output Err(InvalidDigit(6))
Description
Setting the format API to use internal digit separators doesn't work correctly on hex numbers, if those the options for it were created from another set of options.
Prerequisites
Test case
Example test case:
This will output Err(InvalidDigit(6))