pub struct Range<T: Copy> {
pub left: T,
pub right: T,
}
Expand description
A 1d range. Internally represented as start and end. (not start and length) This means that subdivision does not result in any floating point calculations. The left value be <= the right value. There is no protection against “degenerate” Ranges where left>right.
Fields§
§left: T
§right: T
Implementations§
source§impl<T: Copy + PartialOrd> Range<T>
impl<T: Copy + PartialOrd> Range<T>
source§impl<T: Copy + Ord> Range<T>
impl<T: Copy + Ord> Range<T>
sourcepub fn left_or_right_or_contain(&self, pos: &T) -> Ordering
pub fn left_or_right_or_contain(&self, pos: &T) -> Ordering
If the pos is to the left of the range, return less. If the pos is to the right of the range, return greater. If the pos intersects with the range, return equal.
pub fn grow_to_fit(&mut self, b: &Range<T>)
sourcepub fn contains_range(&self, val: &Range<T>) -> bool
pub fn contains_range(&self, val: &Range<T>) -> bool
Returns true if self contains the specified range.
sourcepub fn get_intersection(&self, val: &Range<T>) -> Option<Range<T>>
pub fn get_intersection(&self, val: &Range<T>) -> Option<Range<T>>
Creates a range that represents the intersection range.
sourcepub fn intersects(&self, val: &Range<T>) -> bool
pub fn intersects(&self, val: &Range<T>) -> bool
Returns true if two ranges intersect.