Module lexical_core::format
source · Expand description
Public API for the number format packed struct.
This has a consistent API whether or not the format
feature is
enabled, however, most functionality will be disabled if the feature
is not enabled.
§Pre-Defined Formats
These are the pre-defined formats for parsing numbers from various programming, markup, and data languages.
§Syntax Flags
Bitflags to get and set syntax flags for the format packed struct.
REQUIRED_INTEGER_DIGITS
REQUIRED_FRACTION_DIGITS
REQUIRED_EXPONENT_DIGITS
REQUIRED_MANTISSA_DIGITS
REQUIRED_DIGITS
NO_POSITIVE_MANTISSA_SIGN
REQUIRED_MANTISSA_SIGN
NO_EXPONENT_NOTATION
NO_POSITIVE_EXPONENT_SIGN
REQUIRED_EXPONENT_SIGN
NO_EXPONENT_WITHOUT_FRACTION
NO_SPECIAL
CASE_SENSITIVE_SPECIAL
NO_INTEGER_LEADING_ZEROS
NO_FLOAT_LEADING_ZEROS
REQUIRED_EXPONENT_NOTATION
CASE_SENSITIVE_EXPONENT
CASE_SENSITIVE_BASE_PREFIX
CASE_SENSITIVE_BASE_SUFFIX
§Digit Separator Flags
Bitflags to get and set digit separators flags for the format packed struct.
INTEGER_INTERNAL_DIGIT_SEPARATOR
FRACTION_INTERNAL_DIGIT_SEPARATOR
EXPONENT_INTERNAL_DIGIT_SEPARATOR
INTEGER_LEADING_DIGIT_SEPARATOR
FRACTION_LEADING_DIGIT_SEPARATOR
EXPONENT_LEADING_DIGIT_SEPARATOR
INTEGER_TRAILING_DIGIT_SEPARATOR
FRACTION_TRAILING_DIGIT_SEPARATOR
EXPONENT_TRAILING_DIGIT_SEPARATOR
INTEGER_CONSECUTIVE_DIGIT_SEPARATOR
FRACTION_CONSECUTIVE_DIGIT_SEPARATOR
EXPONENT_CONSECUTIVE_DIGIT_SEPARATOR
INTERNAL_DIGIT_SEPARATOR
LEADING_DIGIT_SEPARATOR
TRAILING_DIGIT_SEPARATOR
CONSECUTIVE_DIGIT_SEPARATOR
SPECIAL_DIGIT_SEPARATOR
§Character Shifts and Masks
Bitmasks and bit shifts to get and set control characters for the format packed struct.
DIGIT_SEPARATOR_SHIFT
DIGIT_SEPARATOR
BASE_PREFIX_SHIFT
BASE_PREFIX
BASE_SUFFIX_SHIFT
BASE_SUFFIX
MANTISSA_RADIX_SHIFT
MANTISSA_RADIX
RADIX_SHIFT
RADIX
EXPONENT_BASE_SHIFT
EXPONENT_BASE
EXPONENT_RADIX_SHIFT
EXPONENT_RADIX
§Character Functions
Functions to get control characters from the format packed struct.
digit_separator
base_prefix
base_suffix
mantissa_radix
exponent_base
exponent_radix
radix_from_flags
§Validators
Functions to validate control characters for the format packed struct.
Structs§
- Build number format from specifications.
Constants§
- Mask to extract the base prefix character.
- Shift to convert to and from a base prefix as a
u8
. - Mask to extract the base suffix character.
- Shift to convert to and from a base suffix as a
u8
. - Base prefixes are case-sensitive.
- Base suffixes are case-sensitive.
- Exponent characters are case-sensitive.
- Special (non-finite) values are case-sensitive.
- Multiple consecutive digit separators are allowed.
- Mask to extract the digit separator character.
- Shift to convert to and from a digit separator as a
u8
. - Mask to extract the exponent base: the base the exponent is raised to.
- Shift to convert to and from an exponent base as a
u32
. - Multiple consecutive exponent digit separators are allowed.
- Digit separators are allowed between exponent digits.
- A digit separator is allowed before any exponent digits.
- Mask to extract the exponent radix: the radix for the exponent digits.
- Shift to convert to and from an exponent radix as a
u32
. - A digit separator is allowed after any exponent digits.
- Multiple consecutive fraction digit separators are allowed.
- Digit separators are allowed between fraction digits.
- A digit separator is allowed before any fraction digits.
- A digit separator is allowed after any fraction digits.
- Multiple consecutive integer digit separators are allowed.
- Digit separators are allowed between integer digits.
- A digit separator is allowed before any integer digits.
- A digit separator is allowed after any integer digits.
- Digit separators are allowed between digits.
- A digit separator is allowed before any digits.
- Mask to extract the mantissa radix: the radix for the significant digits.
- Shift to convert to and from a mantissa radix as a
u32
. - Exponent notation is not allowed.
- Exponent without a fraction component is not allowed.
- Leading zeros before a float value are not allowed.
- Leading zeros before an integer value are not allowed.
- Positive sign before the exponent is not allowed.
- Positive sign before the mantissa is not allowed.
- Special (non-finite) values are not allowed.
- Alias for
MANTISSA_RADIX
. - Alias for
MANTISSA_RADIX_SHIFT
. - At least 1 digit in the number is required.
- Digits are required after the exponent character. This check will only occur if the exponent character is present.
- Exponent notation is required.
- Positive sign before the exponent is required.
- Digits are required after the decimal point. This check will only occur if the decimal point is present.
- Digits are required before the decimal point.
- Mantissa digits are required (either before or after the decimal point).
- Positive sign before the mantissa is required.
- Any digit separators are allowed in special (non-finite) values.
- Standard number format. This is identical to the Rust string format.
- A digit separator is allowed after any digits.
Functions§
- Extract the base prefix character from the format packed struct.
- Extract the base suffix character from the format packed struct.
- Extract the digit separator from the format packed struct.
- Extract the exponent base from the format packed struct. If not provided, defaults to
mantissa_radix
. - Extract the exponent radix from the format packed struct. If not provided, defaults to
mantissa_radix
. - Get the error type from the format packed struct.
- Determine if the format packed struct is valid.
- Determine if the base prefix character is valid.
- Determine if the base suffix character is valid.
- Determine if the digit separator is valid. Digit separators must not be valid digits or sign characters.
- Determine if the provided exponent flags are valid.
- Determine if all of the “punctuation” characters for the options API are valid.
- Determine if all of the “punctuation” characters are valid.
- Determine if the radix is valid.
- Extract the mantissa radix from the format packed struct.
- Extract a generic radix from the format and bitflags.
Type Aliases§
- Type with the exact same size as a
u8
.