diff --git a/lib/src/merge.rs b/lib/src/merge.rs index 56780e3c4..281b84668 100644 --- a/lib/src/merge.rs +++ b/lib/src/merge.rs @@ -311,6 +311,14 @@ impl Merge> { Self::resolved(Some(value)) } + pub fn is_absent(&self) -> bool { + matches!(self.as_resolved(), Some(None)) + } + + pub fn is_present(&self) -> bool { + !self.is_absent() + } + /// Creates lists of `removes` and `adds` from a `Merge` by dropping /// `None` values. Note that the conversion is lossy: the order of `None` /// values is not preserved when converting back to a `Merge`. diff --git a/lib/src/op_store.rs b/lib/src/op_store.rs index 0f56cbc95..c9c468a6e 100644 --- a/lib/src/op_store.rs +++ b/lib/src/op_store.rs @@ -105,13 +105,13 @@ impl RefTarget { /// Returns true if this target points to no commit. pub fn is_absent(&self) -> bool { - matches!(self.merge.as_resolved(), Some(None)) + self.merge.is_absent() } /// Returns true if this target points to any commit. Conflicting target is /// always "present" as it should have at least one commit id. pub fn is_present(&self) -> bool { - !self.is_absent() + self.merge.is_present() } /// Whether this target has conflicts.