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

Method reconstruct_line_from_leaf_ops

atomic-cli/src/commands/diff/helpers.rs:493–513  ·  view source on GitHub ↗

Reconstruct a line's text content from its leaf operations.

(leaf_ops: &[LeafOp])

Source from the content-addressed store, hash-verified

491
492 /// Reconstruct a line's text content from its leaf operations.
493 pub(super) fn reconstruct_line_from_leaf_ops(leaf_ops: &[LeafOp]) -> String {
494 let mut line = String::new();
495 for leaf_op in leaf_ops {
496 match leaf_op {
497 LeafOp::Insert { content, .. } => {
498 if let Ok(text) = std::str::from_utf8(content) {
499 line.push_str(text);
500 }
501 }
502 LeafOp::Replace { new_content, .. } => {
503 if let Ok(text) = std::str::from_utf8(new_content) {
504 line.push_str(text);
505 }
506 }
507 LeafOp::Delete { .. } | LeafOp::Restore { .. } => {
508 // These don't add content to the line
509 }
510 }
511 }
512 line
513 }
514
515 fn is_git_import_change(change: &Change) -> bool {
516 change

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected