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)
| 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 | /// |
no outgoing calls