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

Function parse_fill_and_align

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

Source from the content-addressed store, hash-verified

238}
239
240fn parse_fill_and_align(text: &Wtf8) -> (Option<CodePoint>, Option<FormatAlign>, &Wtf8) {
241 let char_indices: Vec<(usize, CodePoint)> = text.code_point_indices().take(3).collect();
242 if char_indices.is_empty() {
243 (None, None, text)
244 } else if char_indices.len() == 1 {
245 let (maybe_align, remaining) = FormatAlign::parse(text);
246 (None, maybe_align, remaining)
247 } else {
248 let (maybe_align, remaining) = FormatAlign::parse(&text[char_indices[1].0..]);
249 if maybe_align.is_some() {
250 (Some(char_indices[0].1), maybe_align, remaining)
251 } else {
252 let (only_align, only_align_remaining) = FormatAlign::parse(text);
253 (None, only_align, only_align_remaining)
254 }
255 }
256}
257
258fn parse_number(text: &Wtf8) -> Result<(Option<usize>, &Wtf8), FormatSpecError> {
259 let num_digits: usize = get_num_digits(text);

Callers 2

_parseMethod · 0.85
test_fill_and_alignFunction · 0.85

Calls 7

collectMethod · 0.80
code_point_indicesMethod · 0.80
parseFunction · 0.50
SomeClass · 0.50
takeMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by 1

test_fill_and_alignFunction · 0.68