pub trait FromLexicalWithOptions: Number {
type Options: ParseOptions;
fn from_lexical_with_options<const FORMAT: u128>(
bytes: &[u8],
options: &Self::Options
) -> Result<Self>;
fn from_lexical_partial_with_options<const FORMAT: u128>(
bytes: &[u8],
options: &Self::Options
) -> Result<(Self, usize)>;
}
Expand description
Trait for numerical types that can be parsed from bytes with custom options.
The Options
type specifies the configurable options to provide.
Required Associated Types
type Options: ParseOptions
type Options: ParseOptions
Custom formatting options for parsing a number.
Required Methods
Checked parser for a string-to-number conversion.
This method parses the entire string, returning an error if
any invalid digits are found during parsing. The parsing
is dictated by the options, which specifies special
float strings, required float components, digit separators,
exponent characters, and more. Returns a Result
containing
either the parsed value, or an error containing any errors
that occurred during parsing.
FORMAT
- Flags and characters designating the number grammar.bytes
- Slice containing a numeric string.options
- Options to dictate number parsing.
The FORMAT
packed struct is built using NumberFormatBuilder
.
Any invalid number format will prevent parsing, returning
the appropriate format error. If you are unsure which format
to use, use STANDARD
.
Checked parser for a string-to-number conversion.
This method parses until an invalid digit is found (or the end
of the string), returning the number of processed digits
and the parsed value until that point. Returns a Result
containing either the parsed value and the number of
processed digits, or an error containing any errors that
occurred during parsing.
FORMAT
- Flags and characters designating the number grammar.bytes
- Slice containing a numeric string.options
- Options to dictate number parsing.
The FORMAT
packed struct is built using NumberFormatBuilder
.
Any invalid number format will prevent parsing, returning
the appropriate format error. If you are unsure which format
to use, use STANDARD
.