pub fn parse<N: FromLexical>(bytes: &[u8]) -> Result<N>
Expand description

Parse complete number from string.

This method parses the entire string, returning an error if any invalid digits are found during parsing.

  • bytes - Byte slice containing a numeric string.

Example

#[cfg(feature = "parse-floats")] {
let string = "3.14159265359";
let result = lexical_core::parse::<f32>(string.as_bytes());
assert_eq!(result, Ok(3.14159265359_f32));