pub struct BoundedRange<T> {
pub start: LowerBound<T>,
pub end: UpperBound<T>,
}
Expand description
A range bounded both below and above (either inclusive or exclusive).
Generalizes over std::ops::Range
and std::ops::RangeInclusive
but also supports ranges
with an exclusive lower bound.
While a BoundedRange
can be constructed from one of the above types, it will most likely
result from one or more range operations.
use rangetools::{BoundedRange, LowerBound, Rangetools, UpperBound};
let i = (0..5).intersection(3..7);
assert_eq!(i, BoundedRange { start: LowerBound::included(3), end: UpperBound::excluded(5) });
The range is empty if the start bound is greater than the end bound. Note that a range
with start bound Bound::Excluded(3)
and end bound Bound::Excluded(4)
is not considered
empty even though it doesn’t contain any values.
Fields§
§start: LowerBound<T>
The lower bound of the range (can be inclusive or exclusive).
end: UpperBound<T>
The upper bound of the range (can be inclusive or exclusive).
Implementations§
Source§impl<T: Copy + Ord> BoundedRange<T>
impl<T: Copy + Ord> BoundedRange<T>
Sourcepub fn new(start: LowerBound<T>, end: UpperBound<T>) -> Self
pub fn new(start: LowerBound<T>, end: UpperBound<T>) -> Self
Constructs a new BoundedRange
from a lower bound and an upper bound.
§Example
use rangetools::{BoundedRange, LowerBound, UpperBound};
let r = BoundedRange::new(LowerBound::included(0), UpperBound::included(10));
assert!(r.contains(5));
Trait Implementations§
Source§impl<T: Clone> Clone for BoundedRange<T>
impl<T: Clone> Clone for BoundedRange<T>
Source§fn clone(&self) -> BoundedRange<T>
fn clone(&self) -> BoundedRange<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for BoundedRange<T>
impl<T: Debug> Debug for BoundedRange<T>
Source§impl<T: Copy + Ord> From<BoundedRange<T>> for BoundedSet<T>
impl<T: Copy + Ord> From<BoundedRange<T>> for BoundedSet<T>
Source§fn from(r: BoundedRange<T>) -> Self
fn from(r: BoundedRange<T>) -> Self
Converts to this type from the input type.
Source§impl<T> From<BoundedRange<T>> for Range<T>
impl<T> From<BoundedRange<T>> for Range<T>
Source§fn from(r: BoundedRange<T>) -> Self
fn from(r: BoundedRange<T>) -> Self
Converts to this type from the input type.
Source§impl<T> From<BoundedRange<T>> for RangeInclusive<T>
impl<T> From<BoundedRange<T>> for RangeInclusive<T>
Source§fn from(r: BoundedRange<T>) -> Self
fn from(r: BoundedRange<T>) -> Self
Converts to this type from the input type.
Source§impl<T> From<Range<T>> for BoundedRange<T>
impl<T> From<Range<T>> for BoundedRange<T>
Source§impl<T> From<RangeInclusive<T>> for BoundedRange<T>
impl<T> From<RangeInclusive<T>> for BoundedRange<T>
Source§fn from(r: RangeInclusive<T>) -> Self
fn from(r: RangeInclusive<T>) -> Self
Converts to this type from the input type.
Source§impl<T: Hash> Hash for BoundedRange<T>
impl<T: Hash> Hash for BoundedRange<T>
Source§impl<T> IntoIterator for BoundedRange<T>
impl<T> IntoIterator for BoundedRange<T>
Source§impl<T: PartialEq> PartialEq for BoundedRange<T>
impl<T: PartialEq> PartialEq for BoundedRange<T>
Source§impl<T> RangeComplement<UnboundedSet<T>> for BoundedRange<T>
impl<T> RangeComplement<UnboundedSet<T>> for BoundedRange<T>
Source§fn complement(self) -> UnboundedSet<T>
fn complement(self) -> UnboundedSet<T>
Returns a set of all the elements not in
self
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for BoundedRange<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for BoundedRange<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for BoundedSet<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for BoundedSet<T>
Source§type Output = BoundedSet<T>
type Output = BoundedSet<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for LowerBoundedRange<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for LowerBoundedRange<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for LowerBoundedSet<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for LowerBoundedSet<T>
Source§type Output = BoundedSet<T>
type Output = BoundedSet<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for Range<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for Range<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeFrom<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeFrom<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeFullwhere
R: Rangetools<Inner = BoundedRange<T>>,
impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeFullwhere
R: Rangetools<Inner = BoundedRange<T>>,
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeInclusive<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeInclusive<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeTo<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeTo<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeToInclusive<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for RangeToInclusive<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for UnboundedSet<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for UnboundedSet<T>
Source§type Output = BoundedSet<T>
type Output = BoundedSet<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for UpperBoundedRange<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for UpperBoundedRange<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedRange<T>> for UpperBoundedSet<T>
impl<T, R> RangeIntersection<R, BoundedRange<T>> for UpperBoundedSet<T>
Source§type Output = BoundedSet<T>
type Output = BoundedSet<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, BoundedSet<T>> for BoundedRange<T>
impl<T, R> RangeIntersection<R, BoundedSet<T>> for BoundedRange<T>
Source§type Output = BoundedSet<T>
type Output = BoundedSet<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, EmptyRange<T>> for BoundedRange<T>
impl<T, R> RangeIntersection<R, EmptyRange<T>> for BoundedRange<T>
Source§type Output = EmptyRange<T>
type Output = EmptyRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, LowerBoundedRange<T>> for BoundedRange<T>
impl<T, R> RangeIntersection<R, LowerBoundedRange<T>> for BoundedRange<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, LowerBoundedSet<T>> for BoundedRange<T>
impl<T, R> RangeIntersection<R, LowerBoundedSet<T>> for BoundedRange<T>
Source§type Output = BoundedSet<T>
type Output = BoundedSet<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, UnboundedRange> for BoundedRange<T>
impl<T, R> RangeIntersection<R, UnboundedRange> for BoundedRange<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, UnboundedSet<T>> for BoundedRange<T>
impl<T, R> RangeIntersection<R, UnboundedSet<T>> for BoundedRange<T>
Source§type Output = BoundedSet<T>
type Output = BoundedSet<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, UpperBoundedRange<T>> for BoundedRange<T>
impl<T, R> RangeIntersection<R, UpperBoundedRange<T>> for BoundedRange<T>
Source§type Output = BoundedRange<T>
type Output = BoundedRange<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeIntersection<R, UpperBoundedSet<T>> for BoundedRange<T>
impl<T, R> RangeIntersection<R, UpperBoundedSet<T>> for BoundedRange<T>
Source§type Output = BoundedSet<T>
type Output = BoundedSet<T>
The output type of the intersection.
Source§fn intersection(self, other: R) -> Self::Output
fn intersection(self, other: R) -> Self::Output
Returns the set intersection of
self
and other
.Source§impl<T, R> RangeUnion<R, BoundedSet<T>> for BoundedRange<T>
impl<T, R> RangeUnion<R, BoundedSet<T>> for BoundedRange<T>
Source§impl<T, R> RangeUnion<R, EmptyRange<T>> for BoundedRange<T>
impl<T, R> RangeUnion<R, EmptyRange<T>> for BoundedRange<T>
Source§impl<T, R> RangeUnion<R, LowerBoundedSet<T>> for BoundedRange<T>
impl<T, R> RangeUnion<R, LowerBoundedSet<T>> for BoundedRange<T>
Source§impl<T, R> RangeUnion<R, UnboundedRange> for BoundedRange<T>
impl<T, R> RangeUnion<R, UnboundedRange> for BoundedRange<T>
Source§impl<T, R> RangeUnion<R, UnboundedSet<T>> for BoundedRange<T>
impl<T, R> RangeUnion<R, UnboundedSet<T>> for BoundedRange<T>
Source§impl<T, R> RangeUnion<R, UpperBoundedSet<T>> for BoundedRange<T>
impl<T, R> RangeUnion<R, UpperBoundedSet<T>> for BoundedRange<T>
Source§impl<T: Copy + Ord> Rangetools for BoundedRange<T>
impl<T: Copy + Ord> Rangetools for BoundedRange<T>
Source§type Inner = BoundedRange<T>
type Inner = BoundedRange<T>
The generalized type of the range (for consolidating range types that only differ in
whether their bounds are inclusive or exclusive). Read more
Source§type Set = BoundedSet<T>
type Set = BoundedSet<T>
The set type of the range, for talking about non-contiguous collections of
elements. Read more
Source§fn complement<Output>(self) -> Outputwhere
Self: Sized + RangeComplement<Output>,
fn complement<Output>(self) -> Outputwhere
Self: Sized + RangeComplement<Output>,
Source§fn intersection<R, Output>(self, other: R) -> Output
fn intersection<R, Output>(self, other: R) -> Output
Source§fn disjoint<R, Output>(self, other: R) -> boolwhere
R: Rangetools,
Output: Rangetools,
Self: Sized + RangeIntersection<R, R::Inner, Output = Output>,
fn disjoint<R, Output>(self, other: R) -> boolwhere
R: Rangetools,
Output: Rangetools,
Self: Sized + RangeIntersection<R, R::Inner, Output = Output>,
Returns true if two sets/ranges are disjoint (they have no elements in common). Read more
Source§fn intersects<R, Output>(self, other: R) -> boolwhere
R: Rangetools,
Output: Rangetools,
Self: Sized + RangeIntersection<R, R::Inner, Output = Output>,
fn intersects<R, Output>(self, other: R) -> boolwhere
R: Rangetools,
Output: Rangetools,
Self: Sized + RangeIntersection<R, R::Inner, Output = Output>,
Returns true if two sets/ranges intersect (they have at least one element in common). Read more
impl<T: Copy> Copy for BoundedRange<T>
impl<T: Eq> Eq for BoundedRange<T>
impl<T> StructuralPartialEq for BoundedRange<T>
Auto Trait Implementations§
impl<T> Freeze for BoundedRange<T>where
T: Freeze,
impl<T> RefUnwindSafe for BoundedRange<T>where
T: RefUnwindSafe,
impl<T> Send for BoundedRange<T>where
T: Send,
impl<T> Sync for BoundedRange<T>where
T: Sync,
impl<T> Unpin for BoundedRange<T>where
T: Unpin,
impl<T> UnwindSafe for BoundedRange<T>where
T: 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