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

Method try_merge

atomic-core/src/diff/inline.rs:265–277  ·  view source on GitHub ↗

Try to merge with another hunk of the same kind. Returns `Some(merged)` if the hunks are adjacent and same kind, `None` otherwise.

(&self, other: &Self)

Source from the content-addressed store, hash-verified

263 /// Returns `Some(merged)` if the hunks are adjacent and same kind,
264 /// `None` otherwise.
265 pub fn try_merge(&self, other: &Self) -> Option<Self> {
266 if self.kind != other.kind {
267 return None;
268 }
269
270 if self.end == other.start {
271 Some(Self::new(self.start, other.end, self.kind))
272 } else if other.end == self.start {
273 Some(Self::new(other.start, self.end, self.kind))
274 } else {
275 None
276 }
277 }
278
279 /// Extract the content of this hunk from a byte slice.
280 ///

Callers 3

merge_hunksFunction · 0.45

Calls

no outgoing calls

Tested by 1