Function lexical_core::parse_partial

source ·
pub fn parse_partial<N: FromLexical>(bytes: &[u8]) -> Result<(N, usize)>
Expand description

Parse partial number from string.

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.

  • bytes - Byte slice containing a numeric string.

§Example

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