MCPcopy Index your code
hub / github.com/RustPython/RustPython / parse_inner

Function parse_inner

crates/literal/src/float.rs:16–26  ·  view source on GitHub ↗
(literal: &[u8])

Source from the content-addressed store, hash-verified

14}
15
16fn parse_inner(literal: &[u8]) -> Option<f64> {
17 use lexical_parse_float::{
18 FromLexicalWithOptions, NumberFormatBuilder, Options, format::PYTHON3_LITERAL,
19 };
20
21 // lexical-core's format::PYTHON_STRING is inaccurate
22 const PYTHON_STRING: u128 = NumberFormatBuilder::rebuild(PYTHON3_LITERAL)
23 .no_special(false)
24 .build_unchecked();
25 f64::from_lexical_with_options::<PYTHON_STRING>(literal, &Options::new()).ok()
26}
27
28pub fn is_integer(v: f64) -> bool {
29 v.is_finite() && v.fract() == 0.0

Callers 2

parse_strFunction · 0.85
parse_bytesFunction · 0.85

Calls 2

newFunction · 0.85
okMethod · 0.80

Tested by

no test coverage detected