Merge pull request #39 from GoldsteinE/fixed-rule-inputs-count

Add FixedRulePayload::inputs_count()
main
Ziyang Hu 2 years ago committed by GitHub
commit 023372e51d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -302,6 +302,9 @@ impl MagicFixedRuleApply {
);
Ok(rel)
}
pub(crate) fn relations_count(&self) -> usize {
self.rule_args.len()
}
pub(crate) fn relation(&self, idx: usize) -> Result<&MagicFixedRuleRuleArg> {
#[derive(Error, Diagnostic, Debug)]
#[error("Cannot find a required positional argument at index {idx} for '{rule_name}'")]

@ -329,6 +329,10 @@ impl<'a, 'b> FixedRuleInputRelation<'a, 'b> {
}
impl<'a, 'b> FixedRulePayload<'a, 'b> {
/// Get the total number of input relations.
pub fn inputs_count(&self) -> usize {
self.manifest.relations_count()
}
/// Get the input relation at `idx`.
pub fn get_input(&self, idx: usize) -> Result<FixedRuleInputRelation<'a, 'b>> {
let arg_manifest = self.manifest.relation(idx)?;

Loading…
Cancel
Save