Enum Relation

Source
pub enum Relation<T: Domain> {
    Disjoint {
        first: GenericRange<T>,
        second: GenericRange<T>,
        self_less: bool,
    },
    Touching {
        first: GenericRange<T>,
        second: GenericRange<T>,
        self_less: bool,
    },
    Overlapping {
        first_disjoint: GenericRange<T>,
        second_disjoint: GenericRange<T>,
        overlap: GenericRange<T>,
        self_less: bool,
        overlap_is_singleton: bool,
    },
    Containing {
        first_disjoint: GenericRange<T>,
        second_disjoint: GenericRange<T>,
        overlap: GenericRange<T>,
        self_shorter: bool,
    },
    Starting {
        overlap: GenericRange<T>,
        disjoint: GenericRange<T>,
        self_shorter: bool,
        shorter_is_singleton: bool,
    },
    Ending {
        disjoint: GenericRange<T>,
        overlap: GenericRange<T>,
        self_shorter: bool,
        shorter_is_singleton: bool,
    },
    Equal(GenericRange<T>),
    Empty {
        non_empty: Option<GenericRange<T>>,
        self_empty: Option<bool>,
    },
}
Expand description

This enum represents all possible arrangements of two GenericRanges. The original values were moved, possibly modified, and then stored.

§Note

The following information is additionally contained if applicable:

  • which of the two ranges was self and other
  • if the overlap is a singleton
  • if start or other is a singleton
  • which of self and other is shorter

This information is the result of the comparison of the starts and ends of both ranges and is obtained “for free” and should thus be used preferably to other methods like GenericRange::is_singleton().

Variants§

§

Disjoint

The two ranges have no overlap.

§Diagram

first : |----------|
second:               |----------|

Fields

§first: GenericRange<T>

The end of this range is less than the start of second.

§second: GenericRange<T>

The start of this range is greater than the end of first.

§self_less: bool

When GenericRange::relation(self, other) was invoked, either self or other were less.

§

Touching

The two ranges have no overlap but the end of the first touches the start of the second.

§Diagram

first : |----------|
second:            |----------|

Fields

§first: GenericRange<T>

The end of this range touches the start of second.

§second: GenericRange<T>

The start of this range touches the end of first.

§self_less: bool

When GenericRange::relation(self, other) was invoked, either self or other were less when sorted using Ord.

§

Overlapping

The two ranges have an overlap of one or more elements.

§Diagram

first          : |----------|
second         :         |----------|
first disjoint : |-------|
second disjoint:            |-------|
overlap        :         |--|

Fields

§first_disjoint: GenericRange<T>

Range representing the disjoint part of two ranges before the overlap.

§second_disjoint: GenericRange<T>

Range representing the disjoint part of two ranges after the overlap.

§overlap: GenericRange<T>

Range representing the overlapping part of two ranges.

§self_less: bool

When GenericRange::relation(self, other) was invoked, either self or other was less.

§overlap_is_singleton: bool

Indicates whether or not the overlap is by a single element, allowing optimization.

§

Containing

One range is contained in the other.

§Diagram

first          : |--------------------|
second         :      |----------|
first disjoint : |----|
second disjoint:                 |----|
overlap        :      |----------|

Fields

§first_disjoint: GenericRange<T>

Range representing the disjoint part of two ranges before the overlap.

§second_disjoint: GenericRange<T>

Range representing the disjoint part of two ranges after the overlap.

§overlap: GenericRange<T>

Range representing the overlapping part of two ranges.

§self_shorter: bool

When GenericRange::relation(self, other) was invoked, either self or other was shorter.

§

Starting

Both ranges have the same start but varying endings.

§Diagram

first   : |-----|
second  : |----------|
overlap : |-----|
disjoint:       |----|

Fields

§overlap: GenericRange<T>

Range representing the overlapping part of two ranges.

§disjoint: GenericRange<T>

Range representing the disjoint part of two ranges.

§self_shorter: bool

Indicates if self or other in GenericRange::relation(self, other) is shorter.

§shorter_is_singleton: bool

Depending on which of self or other is shorter, this boolean indicates that it is a singleton.

§

Ending

Both ranges have the same end but varying starts.

§Diagram

first   : |----------|
second  :       |----|
disjoint: |-----|
overlap :       |----|

Fields

§disjoint: GenericRange<T>

Range representing the disjoint part of two ranges.

§overlap: GenericRange<T>

Range representing the overlapping part of two ranges.

§self_shorter: bool

Indicates if self or other in GenericRange::relation(self, other) is shorter.

§shorter_is_singleton: bool

Depending on which of self or other is shorter, this boolean indicates that it is a singleton.

§

Equal(GenericRange<T>)

The starts and ends of both ranges are equal.

§Diagram

first : |----------|
second: |----------|
equal : |----------|
§

Empty

One or both ranges are empty and can therefore not be compared.

§Diagram

first    :
second   :    |----|
non_empty:    |----|

Fields

§non_empty: Option<GenericRange<T>>

The non empty range of the two ranges, if it exists.

§self_empty: Option<bool>

Indicates which of the two inputs of GenericRange::arrangement(&self, &other) were empty. Returns None if both were empty.

Trait Implementations§

Source§

impl<T: Debug + Domain> Debug for Relation<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: PartialEq + Domain> PartialEq for Relation<T>

Source§

fn eq(&self, other: &Relation<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq + Domain> Eq for Relation<T>

Source§

impl<T: Domain> StructuralPartialEq for Relation<T>

Auto Trait Implementations§

§

impl<T> Freeze for Relation<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Relation<T>
where T: RefUnwindSafe,

§

impl<T> Send for Relation<T>
where T: Send,

§

impl<T> Sync for Relation<T>
where T: Sync,

§

impl<T> Unpin for Relation<T>
where T: Unpin,

§

impl<T> UnwindSafe for Relation<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.