pub trait FromLexicalWithOptions: Number {
    type Options: ParseOptions;

    // Required methods
    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§

source

type Options: ParseOptions

Custom formatting options for parsing a number.

Required Methods§

source

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

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.

source

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl FromLexicalWithOptions for i8

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for i16

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for i32

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for i64

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for i128

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for isize

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for u8

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for u16

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for u32

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for u64

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for u128

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

source§

impl FromLexicalWithOptions for usize

source§

type Options = Options

source§

fn from_lexical_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<Self>

source§

fn from_lexical_partial_with_options<const FORMAT: u128>( bytes: &[u8], options: &Self::Options, ) -> Result<(Self, usize)>

Implementors§