pub fn detect_conflicts(a: &BTreeSet<Path>, b: &BTreeSet<Path>) -> Vec<Conflict>Expand description
Detect conflicts between two sets of touched paths.
A conflict occurs when:
- Both sets contain the exact same path (ExactMatch)
- One path is a prefix of another (PrefixConflict)
ยงExamples
use tirea_state::{path, compute_touched, detect_conflicts, Patch, Op, ConflictKind};
use serde_json::json;
let patch_a = Patch::new()
.with_op(Op::set(path!("user"), json!({"name": "Alice"})));
let patch_b = Patch::new()
.with_op(Op::set(path!("user", "name"), json!("Bob")));
let touched_a = compute_touched(&patch_a, false);
let touched_b = compute_touched(&patch_b, false);
let conflicts = detect_conflicts(&touched_a, &touched_b);
assert!(!conflicts.is_empty());
assert!(conflicts.iter().any(|c| c.kind == ConflictKind::PrefixConflict));