pub struct Range<T> {
pub start: T,
pub end: T,
}
Expand description
A range of elements, including the endpoints.
Fields
start: T
end: T
Implementations
sourceimpl<T: PrimInt> Range<T>
impl<T: PrimInt> Range<T>
sourcepub fn new(start: T, end: T) -> Range<T>
pub fn new(start: T, end: T) -> Range<T>
Creates a new range with the given start and endpoints (inclusive).
Panics
- if
start
is strictly larger thanend
sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
Checks whether the intersections overlap.
sourcepub fn intersection(&self, other: &Self) -> Option<Self>
pub fn intersection(&self, other: &Self) -> Option<Self>
Computes the intersection between two ranges. Returns none if the intersection is empty.
Trait Implementations
sourceimpl<T: Debug + PrimInt> FromIterator<Range<T>> for RangeSet<T>
impl<T: Debug + PrimInt> FromIterator<Range<T>> for RangeSet<T>
sourcefn from_iter<I: IntoIterator<Item = Range<T>>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Range<T>>>(iter: I) -> Self
Builds a RangeSet
from an iterator over Range
s.
sourceimpl<T: Ord> Ord for Range<T>
impl<T: Ord> Ord for Range<T>
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: PartialEq> PartialEq<Range<T>> for Range<T>
impl<T: PartialEq> PartialEq<Range<T>> for Range<T>
sourceimpl<T: PartialOrd> PartialOrd<Range<T>> for Range<T>
impl<T: PartialOrd> PartialOrd<Range<T>> for Range<T>
sourcefn partial_cmp(&self, other: &Range<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Range<T>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl<T: PrimInt> PartialOrd<T> for Range<T>
impl<T: PrimInt> PartialOrd<T> for Range<T>
impl<T: Copy> Copy for Range<T>
impl<T: Eq> Eq for Range<T>
impl<T> StructuralEq for Range<T>
impl<T> StructuralPartialEq for Range<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Range<T>where
T: RefUnwindSafe,
impl<T> Send for Range<T>where
T: Send,
impl<T> Sync for Range<T>where
T: Sync,
impl<T> Unpin for Range<T>where
T: Unpin,
impl<T> UnwindSafe for Range<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more