Returns true if and only if the two ranges are contiguous. Two ranges are contiguous if and only if the ranges are either overlapping or adjacent.
(&self, other: &Self)
| 427 | /// are contiguous if and only if the ranges are either overlapping or |
| 428 | /// adjacent. |
| 429 | fn is_contiguous(&self, other: &Self) -> bool { |
| 430 | let lower1 = self.lower().as_u32(); |
| 431 | let upper1 = self.upper().as_u32(); |
| 432 | let lower2 = other.lower().as_u32(); |
| 433 | let upper2 = other.upper().as_u32(); |
| 434 | cmp::max(lower1, lower2) <= cmp::min(upper1, upper2).saturating_add(1) |
| 435 | } |
| 436 | |
| 437 | /// Returns true if and only if the intersection of this range and the |
| 438 | /// other range is empty. |