MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / replacement_for

Function replacement_for

atomic-core/src/merge/three_way.rs:287–301  ·  view source on GitHub ↗

For a given base index, return the replacement content (if any). `None` means the token was deleted rather than replaced.

(ops: &[EditOp], base_idx: usize)

Source from the content-addressed store, hash-verified

285/// For a given base index, return the replacement content (if any).
286/// `None` means the token was deleted rather than replaced.
287fn replacement_for(ops: &[EditOp], base_idx: usize) -> Option<Vec<u8>> {
288 for op in ops {
289 match op {
290 EditOp::Replace(idx, content) if *idx == base_idx => {
291 return Some(content.clone());
292 }
293 EditOp::Delete(idx) if *idx == base_idx => {
294 return None;
295 }
296 _ => {}
297 }
298 }
299 // Not modified — return the sentinel "keep".
300 Some(Vec::new())
301}
302
303/// Collect all insertions keyed by the base index they follow.
304fn insert_positions(ops: &[EditOp]) -> HashMap<usize, Vec<Vec<u8>>> {

Callers 1

three_way_mergeFunction · 0.85

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected