pub struct Interval<Ix> {
pub start: Ix,
pub end: Ix,
}Expand description
A half-open interval [start, end).
This is a helper struct used internally for interval operations.
Intervals are represented as half-open ranges matching Rust’s Range<T>.
Fields§
§start: IxThe inclusive start of the interval.
end: IxThe exclusive end of the interval.
Implementations§
Source§impl<Ix: IndexType> Interval<Ix>
impl<Ix: IndexType> Interval<Ix>
Sourcepub fn contains_point(&self, point: Ix) -> bool
pub fn contains_point(&self, point: Ix) -> bool
Returns true if this interval contains the given point.
A point p is contained if start <= p < end.
Sourcepub fn overlaps(&self, other: &Interval<Ix>) -> bool
pub fn overlaps(&self, other: &Interval<Ix>) -> bool
Returns true if this interval overlaps with another.
Two intervals overlap if they share at least one point.
Trait Implementations§
Source§impl<Ix: IndexType> From<RangeInclusive<Ix>> for Interval<Ix>
impl<Ix: IndexType> From<RangeInclusive<Ix>> for Interval<Ix>
Source§fn from(range: RangeInclusive<Ix>) -> Self
fn from(range: RangeInclusive<Ix>) -> Self
Converts an inclusive range a..=b to a half-open interval [a, b+1).
§Panics
Panics if b == Ix::MAX since b + 1 would overflow.
impl<Ix: Copy> Copy for Interval<Ix>
impl<Ix: Eq> Eq for Interval<Ix>
impl<Ix> StructuralPartialEq for Interval<Ix>
Auto Trait Implementations§
impl<Ix> Freeze for Interval<Ix>where
Ix: Freeze,
impl<Ix> RefUnwindSafe for Interval<Ix>where
Ix: RefUnwindSafe,
impl<Ix> Send for Interval<Ix>where
Ix: Send,
impl<Ix> Sync for Interval<Ix>where
Ix: Sync,
impl<Ix> Unpin for Interval<Ix>where
Ix: Unpin,
impl<Ix> UnwindSafe for Interval<Ix>where
Ix: UnwindSafe,
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