pub fn compute_touched(patch: &Patch, include_parents: bool) -> BTreeSet<Path>Expand description
Compute the set of paths touched by a patch.
§Arguments
patch- The patch to analyzeinclude_parents- If true, include all parent paths. For example, if the patch modifies “a.b.c”, the result will include “a”, “a.b”, and “a.b.c”.
§Examples
use tirea_state::{Patch, Op, path, compute_touched};
let patch = Patch::new()
.with_op(Op::set(path!("user", "name"), serde_json::json!("Alice")))
.with_op(Op::set(path!("user", "age"), serde_json::json!(30)));
// Without parents
let touched = compute_touched(&patch, false);
assert!(touched.contains(&path!("user", "name")));
assert!(touched.contains(&path!("user", "age")));
assert!(!touched.contains(&path!("user")));
// With parents
let touched_with_parents = compute_touched(&patch, true);
assert!(touched_with_parents.contains(&path!("user")));
assert!(touched_with_parents.contains(&path!("user", "name")));