Enum range_set::range_compare::RangeDisjoint
source · pub enum RangeDisjoint {
EmptyBoth,
EmptyLhs,
EmptyRhs,
LessThanProper,
LessThanAdjacent,
GreaterThanProper,
GreaterThanAdjacent,
}
Expand description
Ways in which a pair of ranges (A,B)
can be disjoint
Variants§
EmptyBoth
A = B = {}
EmptyLhs
A = {}
EmptyRhs
B = {}
LessThanProper
[ A ] [ B ]
LessThanAdjacent
[ A ][ B ]
GreaterThanProper
[ B ] [ A ]
GreaterThanAdjacent
[ B ][ A ]
Implementations§
source§impl RangeDisjoint
impl RangeDisjoint
sourcepub fn compare<T: PrimInt>(
left: &RangeInclusive<T>,
right: &RangeInclusive<T>
) -> Option<Self>
pub fn compare<T: PrimInt>( left: &RangeInclusive<T>, right: &RangeInclusive<T> ) -> Option<Self>
Tests two inclusive ranges for disjointness, returning None
if they
intersect.
assert_eq!(RangeDisjoint::compare (&(0..=5), &(0..=5)), None);
assert_eq!(
RangeDisjoint::compare (&(1..=0), &(1..=0)),
Some (RangeDisjoint::EmptyBoth));
assert_eq!(
RangeDisjoint::compare (&(1..=0), &(0..=5)),
Some (RangeDisjoint::EmptyLhs));
assert_eq!(
RangeDisjoint::compare (&(0..=5), &(1..=0)),
Some (RangeDisjoint::EmptyRhs));
assert_eq!(
RangeDisjoint::compare (&(0..=2), &(4..=5)),
Some (RangeDisjoint::LessThanProper));
assert_eq!(
RangeDisjoint::compare (&(0..=2), &(3..=5)),
Some (RangeDisjoint::LessThanAdjacent));
assert_eq!(
RangeDisjoint::compare (&(4..=5), &(0..=2)),
Some (RangeDisjoint::GreaterThanProper));
assert_eq!(
RangeDisjoint::compare (&(3..=5), &(0..=2)),
Some (RangeDisjoint::GreaterThanAdjacent));
Trait Implementations§
source§impl Debug for RangeDisjoint
impl Debug for RangeDisjoint
source§impl From<RangeDisjoint> for RangeCompare
impl From<RangeDisjoint> for RangeCompare
source§fn from(disjoint: RangeDisjoint) -> Self
fn from(disjoint: RangeDisjoint) -> Self
Converts to this type from the input type.
source§impl PartialEq for RangeDisjoint
impl PartialEq for RangeDisjoint
source§fn eq(&self, other: &RangeDisjoint) -> bool
fn eq(&self, other: &RangeDisjoint) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for RangeDisjoint
impl StructuralEq for RangeDisjoint
impl StructuralPartialEq for RangeDisjoint
Auto Trait Implementations§
impl RefUnwindSafe for RangeDisjoint
impl Send for RangeDisjoint
impl Sync for RangeDisjoint
impl Unpin for RangeDisjoint
impl UnwindSafe for RangeDisjoint
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more