pub enum Range<A = i32> {
Single(A),
Bounded(A, A),
UnboundedL(A),
UnboundedR(A),
Unbounded,
}Variants§
Implementations§
Source§impl<A> Range<A>
impl<A> Range<A>
Sourcepub fn is_lower_or_upper_bounded(&self) -> bool
pub fn is_lower_or_upper_bounded(&self) -> bool
Whether the range is bounded on either side. A bounded range may still be infinite. See also: Range::is_finite.
Sourcepub fn is_unbounded(&self) -> bool
pub fn is_unbounded(&self) -> bool
Whether the range is unbounded on both sides.
Sourcepub fn is_finite(&self) -> bool
pub fn is_finite(&self) -> bool
Whether the range is finite. See also: Range::is_lower_or_upper_bounded.
Source§impl<A: Ord + Clone> Range<A>
impl<A: Ord + Clone> Range<A>
Source§impl<A: Num + Ord + Clone> Range<A>
impl<A: Num + Ord + Clone> Range<A>
pub fn length(&self) -> Option<A>
Sourcepub fn overlaps(&self, other: &Range<A>) -> bool
pub fn overlaps(&self, other: &Range<A>) -> bool
Returns true if this interval overlaps another one, i.e. at least one
number is part of both self and other
E.g:
- [0, 2] overlaps [2, 4]
- [1, 3] overlaps [2, 4]
- [4, 6] overlaps [2, 4]
Sourcepub fn touches_left(&self, other: &Range<A>) -> bool
pub fn touches_left(&self, other: &Range<A>) -> bool
Returns true if this interval touches another one on the left E.g: [1, 2] touches_left [3, 4]
Sourcepub fn touches_right(&self, other: &Range<A>) -> bool
pub fn touches_right(&self, other: &Range<A>) -> bool
Returns true if this interval touches another one on the right E.g: [3, 4] touches_right [1, 2]
Sourcepub fn joins(&self, other: &Range<A>) -> bool
pub fn joins(&self, other: &Range<A>) -> bool
Returns true if this interval overlaps or touches another one E.g:
- [1, 3] joins [4, 6]
- [2, 4] joins [4, 6]
- [3, 5] joins [4, 6]
- [6, 8] joins [4, 6]
- [7, 8] joins [4, 6]
Sourcepub fn is_before(&self, other: &Range<A>) -> bool
pub fn is_before(&self, other: &Range<A>) -> bool
Returns true if this interval is strictly before another one
Sourcepub fn is_after(&self, other: &Range<A>) -> bool
pub fn is_after(&self, other: &Range<A>) -> bool
Returns true if this interval is strictly after another one
Sourcepub fn join(&self, other: &Range<A>) -> Option<Range<A>>
pub fn join(&self, other: &Range<A>) -> Option<Range<A>>
If the two ranges join, return a new range which spans both
Sourcepub fn iter(&self) -> Option<RangeIterator<A>>
pub fn iter(&self) -> Option<RangeIterator<A>>
If this range is bounded, returns a lazy iterator over all values within the range. Otherwise, returns None.
pub fn values(rngs: &[Range<A>]) -> Option<impl Iterator<Item = A>>
Trait Implementations§
Source§impl<'de, A> Deserialize<'de> for Range<A>where
A: Deserialize<'de>,
impl<'de, A> Deserialize<'de> for Range<A>where
A: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<A> Quine for Range<A>where
A: Quine,
impl<A> Quine for Range<A>where
A: Quine,
fn ctor_tokens(&self) -> TokenStream
impl<A: Eq> Eq for Range<A>
impl<A> StructuralPartialEq for Range<A>
Auto Trait Implementations§
impl<A> Freeze for Range<A>where
A: Freeze,
impl<A> RefUnwindSafe for Range<A>where
A: RefUnwindSafe,
impl<A> Send for Range<A>where
A: Send,
impl<A> Sync for Range<A>where
A: Sync,
impl<A> Unpin for Range<A>where
A: Unpin,
impl<A> UnwindSafe for Range<A>where
A: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.