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)
| 285 | /// For a given base index, return the replacement content (if any). |
| 286 | /// `None` means the token was deleted rather than replaced. |
| 287 | fn 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. |
| 304 | fn insert_positions(ops: &[EditOp]) -> HashMap<usize, Vec<Vec<u8>>> { |
no test coverage detected