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

Function parse_number

crates/common/src/format.rs:258–269  ·  view source on GitHub ↗
(text: &Wtf8)

Source from the content-addressed store, hash-verified

256}
257
258fn parse_number(text: &Wtf8) -> Result<(Option<usize>, &Wtf8), FormatSpecError> {
259 let num_digits: usize = get_num_digits(text);
260 if num_digits == 0 {
261 return Ok((None, text));
262 }
263 if let Some(num) = parse_usize(&text[..num_digits]) {
264 Ok((Some(num), &text[num_digits..]))
265 } else {
266 // NOTE: this condition is different from CPython
267 Err(FormatSpecError::DecimalDigitsTooMany)
268 }
269}
270
271fn parse_alternate_form(text: &Wtf8) -> (bool, &Wtf8) {
272 let mut chars = text.code_points();

Callers 2

parse_precisionFunction · 0.85
_parseMethod · 0.85

Calls 4

get_num_digitsFunction · 0.85
parse_usizeFunction · 0.85
SomeClass · 0.50
ErrClass · 0.50

Tested by

no test coverage detected