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

Function extract

src/debug_utils/generic_function/parse.rs:25–35  ·  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

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

Callers 7

parse_entityFunction · 0.70
parse_value_declarationFunction · 0.70
parse_block_labelFunction · 0.70
parse_opcodeFunction · 0.70
parse_operandFunction · 0.70
parse_constraintFunction · 0.70
parse_instructionFunction · 0.70

Calls 2

mapMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected