Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

Downgrades datalogic-rs dependency from version 4 to version 3 per project requirements.

Changes

  • Cargo.toml: datalogic-rs = "4.0""3.0" (resolves to v3.1.1)

  • Custom operator trait migration: All operators (FractionalOperator, StartsWithOperator, EndsWithOperator, SemVerOperator) migrated from v4's Operator trait to v3's CustomOperator trait with arena-based allocation

    • Method: add_operator()register_custom_operator()
    • Signature: Returns &'a DataValue<'a> via arena instead of owned Value
    • Imports: ContextStack, Error, EvaluatorCustomOperator, DataArena, EvalContext, LogicError
  • Evaluation calls: evaluate_json(str, str)evaluate_str(str, str) due to v3 signature changes

API Example

Before (v4):

impl Operator for FractionalOperator {
    fn evaluate(&self, args: &[Value], context: &mut ContextStack, _: &dyn Evaluator) 
        -> Result<Value> {
        Ok(Value::String(result))
    }
}
logic.add_operator("fractional".to_string(), Box::new(FractionalOperator));

After (v3):

impl CustomOperator for FractionalOperator {
    fn evaluate<'a>(&self, args: &'a [DataValue<'a>], _: &EvalContext<'a>, arena: &'a DataArena) 
        -> Result<&'a DataValue<'a>> {
        let s = arena.alloc_str(&result);
        Ok(arena.alloc(DataValue::String(s)))
    }
}
logic.register_custom_operator("fractional", Box::new(FractionalOperator));

Behavior Change

Missing variables now return null per JSON Logic spec (v3 behavior) rather than throwing errors (v4 behavior). Updated test_eval_fractional_missing_var to reflect spec-compliant behavior.

Original prompt

I want to switch to datalogic-rs version 3 instead of 4. Open a pull request with the changes please


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 3, 2025 21:00
Co-authored-by: aepfli <9987394+aepfli@users.noreply.github.com>
Co-authored-by: aepfli <9987394+aepfli@users.noreply.github.com>
Copilot AI changed the title [WIP] Update datalogic-rs from version 4 to version 3 Switch from datalogic-rs v4 to v3 Dec 3, 2025
Copilot AI requested a review from aepfli December 3, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants