parse_partial_with_options

Function parse_partial_with_options 

Source
pub fn parse_partial_with_options<N: FromLexicalWithOptions, const FORMAT: u128>(
    bytes: &[u8],
    options: &N::Options,
) -> Result<(N, usize)>
Available on crate features parse-floats or parse-integers only.
Expand description

Parse partial number from string with custom parsing options.

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.

  • FORMAT - Packed struct containing the number format.
  • bytes - Byte slice containing a numeric string.
  • options - Options to customize number parsing.

ยงExamples

const JSON: u128 = lexical_core::format::JSON;
const OPTIONS: lexical_core::ParseFloatOptions = lexical_core::ParseFloatOptions::new();
let string = "3.14159265359 hello";
let result = lexical_core::parse_partial_with_options::<f32, JSON>(string.as_bytes(), &OPTIONS);
assert_eq!(result, Ok((3.14159265359_f32, 13)));