pub trait IntervalIterator<E: PartialOrd> {
type IntervalIter: Iterator<Item = RangeInclusive<E>>;
// Required method
fn intervals(&self) -> Self::IntervalIter;
// Provided methods
fn card(&self) -> Option<usize>
where E: Step { ... }
fn contains(&self, elem: &E) -> bool { ... }
fn diff<O, R>(&self, other: &O) -> R
where E: Clone + Adjacent,
O: IntervalIterator<E>,
R: FromIterator<RangeInclusive<E>> { ... }
fn disjoint<O: IntervalIterator<E> + ?Sized>(&self, other: &O) -> bool { ... }
fn intersect<O, R>(&self, other: &O) -> R
where E: Clone,
O: IntervalIterator<E>,
R: FromIterator<RangeInclusive<E>> { ... }
fn subset<O: IntervalIterator<E> + ?Sized>(&self, other: &O) -> bool { ... }
fn superset<O: IntervalIterator<E> + ?Sized>(&self, other: &O) -> bool { ... }
fn union<O, R>(&self, other: &O) -> R
where E: Clone,
O: IntervalIterator<E>,
R: FromIterator<RangeInclusive<E>> { ... }
}Expand description
A trait that provides operations on iterators of orderdered intervals.
Required Associated Types§
Sourcetype IntervalIter: Iterator<Item = RangeInclusive<E>>
type IntervalIter: Iterator<Item = RangeInclusive<E>>
The type of the interval iterator.
Required Methods§
Sourcefn intervals(&self) -> Self::IntervalIter
fn intervals(&self) -> Self::IntervalIter
Returns an iterator over the ordered intervals.
Provided Methods§
Sourcefn card(&self) -> Option<usize>where
E: Step,
fn card(&self) -> Option<usize>where
E: Step,
Returns the number of elements contained within the RangeList.
Returns None if the number of elements would overflow usize.
Sourcefn contains(&self, elem: &E) -> bool
fn contains(&self, elem: &E) -> bool
Returns true if elem is contained in the range list.
§Examples
assert!(RangeList::from_iter([1..=4]).contains(&4));
assert!(!RangeList::from_iter([1..=4]).contains(&0));
assert!(RangeList::from_iter([1..=4, 6..=7, -5..=-3]).contains(&7));
assert!(!RangeList::from_iter([1..=4, 6..=7, -5..=-3]).contains(&0));Sourcefn diff<O, R>(&self, other: &O) -> R
fn diff<O, R>(&self, other: &O) -> R
Compute RangeList without any of the elements in the ranges of other.
§Warning
The implementation decrements the lowest value of self and increments
the largest value of self. This could cause a panic if this causes
overflow in E.
Sourcefn disjoint<O: IntervalIterator<E> + ?Sized>(&self, other: &O) -> bool
fn disjoint<O: IntervalIterator<E> + ?Sized>(&self, other: &O) -> bool
Returns whether self and other are disjoint sets
Sourcefn intersect<O, R>(&self, other: &O) -> R
fn intersect<O, R>(&self, other: &O) -> R
Return the set intersection of two interval iterators.
Sourcefn subset<O: IntervalIterator<E> + ?Sized>(&self, other: &O) -> bool
fn subset<O: IntervalIterator<E> + ?Sized>(&self, other: &O) -> bool
Returns whether self is a subset of other
Sourcefn superset<O: IntervalIterator<E> + ?Sized>(&self, other: &O) -> bool
fn superset<O: IntervalIterator<E> + ?Sized>(&self, other: &O) -> bool
Returns whether self is a superset of other
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".