pub struct AnyRange<T>(/* private fields */)
where
T: NumericInteger;Expand description
The set type this crate operates on, and the range type its constructors take, are
irange’s. They are re-exported here so that a dependent needs neither its own
dependency on irange nor a version kept in step with this crate’s.
A range of integers, held as an inclusive (min, max) pair.
A range where min > max is empty and is ignored by RangeSet::new_from_ranges.
Implementations§
Source§impl<T> AnyRange<T>where
T: NumericInteger,
impl<T> AnyRange<T>where
T: NumericInteger,
Sourcepub fn new(min: T, max: T) -> AnyRange<T>
pub fn new(min: T, max: T) -> AnyRange<T>
Create a range from the given inclusive bounds.
The range is empty if min > max.
Sourcepub fn from<R>(range: R) -> AnyRange<T>where
R: RangeBounds<T>,
pub fn from<R>(range: R) -> AnyRange<T>where
R: RangeBounds<T>,
Create a range from any Rust range, inclusive or not, bounded or not.
The range is empty if it holds no value, e.g. 2..2 or ..T::MIN.
§Example:
use irange::range::AnyRange;
// Holds 3, 4
assert_eq!(&(3, 4), AnyRange::from(3..5).get_bounds());
// Holds 0, 1, 2
assert_eq!(&(0, 2), AnyRange::<u8>::from(..=2).get_bounds());
assert!(AnyRange::from(2..2).is_empty());Sourcepub fn get_bounds(&self) -> &(T, T)
pub fn get_bounds(&self) -> &(T, T)
Return the inclusive (min, max) bounds of the range.
min is greater than max when the range is empty.
Trait Implementations§
impl<T> Copy for AnyRange<T>where
T: Copy + NumericInteger,
impl<T> Eq for AnyRange<T>where
T: Eq + NumericInteger,
Source§impl<T> FromIterator<AnyRange<T>> for RangeSet<T>where
T: NumericInteger,
impl<T> FromIterator<AnyRange<T>> for RangeSet<T>where
T: NumericInteger,
Source§fn from_iter<I>(iter: I) -> RangeSet<T>where
I: IntoIterator<Item = AnyRange<T>>,
fn from_iter<I>(iter: I) -> RangeSet<T>where
I: IntoIterator<Item = AnyRange<T>>,
Collect the given ranges into a single set, like RangeSet::new_from_ranges.
§Example:
use irange::range::AnyRange;
use irange::RangeSet;
let range: RangeSet<i64> = [3..=4, 7..=8].into_iter().map(AnyRange::from).collect();
assert_eq!("[ 3..=4 7..=8 ]", range.to_string());Source§impl<T> Ord for AnyRange<T>where
T: Ord + NumericInteger,
impl<T> Ord for AnyRange<T>where
T: Ord + NumericInteger,
1.21.0 (const: unstable) · Source§fn 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 (const: unstable) · Source§fn 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
Source§impl<T> PartialOrd for AnyRange<T>where
T: PartialOrd + NumericInteger,
impl<T> PartialOrd for AnyRange<T>where
T: PartialOrd + NumericInteger,
impl<T> StructuralPartialEq for AnyRange<T>where
T: PartialEq + NumericInteger,
Auto Trait Implementations§
impl<T> Freeze for AnyRange<T>
impl<T> RefUnwindSafe for AnyRange<T>where
(T, T): RefUnwindSafe,
impl<T> Send for AnyRange<T>
impl<T> Sync for AnyRange<T>
impl<T> Unpin for AnyRange<T>
impl<T> UnsafeUnpin for AnyRange<T>where
(T, T): UnsafeUnpin,
impl<T> UnwindSafe for AnyRange<T>where
(T, 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