Trait lexical_parse_float::FromLexical

source ·
pub trait FromLexical: Number {
    // Required methods
    fn from_lexical(bytes: &[u8]) -> Result<Self>;
    fn from_lexical_partial(bytes: &[u8]) -> Result<(Self, usize)>;
}
Expand description

Trait for numerical types that can be parsed from bytes.

Required Methods§

source

fn from_lexical(bytes: &[u8]) -> 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. Returns a Result containing either the parsed value, or an error containing any errors that occurred during parsing.

  • bytes - Slice containing a numeric string.
source

fn from_lexical_partial(bytes: &[u8]) -> 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.

  • bytes - Slice containing a numeric string.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl FromLexical for f32

source§

fn from_lexical(bytes: &[u8]) -> Result<Self>

source§

fn from_lexical_partial(bytes: &[u8]) -> Result<(Self, usize)>

source§

impl FromLexical for f64

source§

fn from_lexical(bytes: &[u8]) -> Result<Self>

source§

fn from_lexical_partial(bytes: &[u8]) -> Result<(Self, usize)>

Implementors§