Decide if this interval is certainly equal to, possibly equal to, or can't be equal to `other` by returning `[true, true]`, `[false, true]` or `[false, false]` respectively. NOTE: This function only works with intervals of the same data type. Attempting to compare intervals of different data types will lead to an error.
(&self, other: T)
| 553 | /// Attempting to compare intervals of different data types will lead |
| 554 | /// to an error. |
| 555 | pub fn equal<T: Borrow<Self>>(&self, other: T) -> Result<Self> { |
| 556 | let rhs = other.borrow(); |
| 557 | let types_compatible = |
| 558 | BinaryTypeCoercer::new(&self.data_type(), &Operator::Eq, &rhs.data_type()) |
| 559 | .get_result_type() |
| 560 | .is_ok(); |
| 561 | assert_or_internal_err!( |
| 562 | types_compatible, |
| 563 | "Interval data types must be compatible for equality checks, lhs:{}, rhs:{}", |
| 564 | self.data_type(), |
| 565 | rhs.data_type() |
| 566 | ); |
| 567 | if !self.lower.is_null() |
| 568 | && (self.lower == self.upper) |
| 569 | && (rhs.lower == rhs.upper) |
| 570 | && (self.lower == rhs.lower) |
| 571 | { |
| 572 | Ok(Self::TRUE) |
| 573 | } else if self.intersect(rhs)?.is_none() { |
| 574 | Ok(Self::FALSE) |
| 575 | } else { |
| 576 | Ok(Self::TRUE_OR_FALSE) |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | /// Compute the logical conjunction of this (boolean) interval with the |
| 581 | /// given boolean interval. |