pub fn diff(old: &Statute, new: &Statute) -> DiffResult<StatuteDiff>Expand description
Computes the diff between two statutes.
§Examples
use legalis_core::{Statute, Effect, EffectType, Condition, ComparisonOp};
use legalis_diff::diff;
let old = Statute::new(
"tax-credit",
"Tax Credit for Seniors",
Effect::new(EffectType::Grant, "Tax credit granted"),
).with_precondition(Condition::Age {
operator: ComparisonOp::GreaterOrEqual,
value: 65,
});
let mut new = old.clone();
new.title = "Enhanced Tax Credit for Seniors".to_string();
let result = diff(&old, &new).unwrap();
assert_eq!(result.changes.len(), 1);
assert!(result.changes[0].description.contains("Title"));§Errors
Returns DiffError::IdMismatch if the statute IDs don’t match.