MCPcopy Create free account
hub / github.com/Amanieu/regalloc3 / extract

Function extract

src/debug_utils/generic_reginfo/parse.rs:22–32  ·  view source on GitHub ↗

Helper function to extract N sub-pairs when the layout of a rule is fixed.

(pair: Pair<'_, Rule>, expected_rules: [Rule; N])

Source from the content-addressed store, hash-verified

20
21/// Helper function to extract N sub-pairs when the layout of a rule is fixed.
22fn extract<const N: usize>(pair: Pair<'_, Rule>, expected_rules: [Rule; N]) -> [Pair<'_, Rule>; N] {
23 let mut out = [(); N].map(|()| pair.clone());
24 let mut i = 0;
25 for pair in pair.into_inner() {
26 assert_eq!(pair.as_rule(), expected_rules[i]);
27 out[i] = pair;
28 i += 1;
29 }
30 assert_eq!(i, N);
31 out
32}
33
34/// Helper function to emit a custom error at the given span.
35fn custom_error(span: Span<'_>, msg: &str) -> Error<Rule> {

Callers 5

parse_entityFunction · 0.70
parse_reg_defFunction · 0.70
parse_reg_group_defFunction · 0.70
parse_class_defFunction · 0.70
parse_bank_defFunction · 0.70

Calls 2

mapMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected