Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FixedRulePayload::inputs_count() #39

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cozo-core/src/data/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}'")]
Expand Down
4 changes: 4 additions & 0 deletions cozo-core/src/fixed_rule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down