pub struct Range<V> { /* private fields */ }
Expand description
A Range represents multiple intervals of a continuous range of monotone increasing values.
Implementations§
source§impl<V> Range<V>
impl<V> Range<V>
sourcepub fn higher_than(v: impl Into<V>) -> Self
pub fn higher_than(v: impl Into<V>) -> Self
Set of all versions higher or equal to some version
sourcepub fn strictly_higher_than(v: impl Into<V>) -> Self
pub fn strictly_higher_than(v: impl Into<V>) -> Self
Set of all versions higher to some version
sourcepub fn strictly_lower_than(v: impl Into<V>) -> Self
pub fn strictly_lower_than(v: impl Into<V>) -> Self
Set of all versions lower to some version
sourcepub fn lower_than(v: impl Into<V>) -> Self
pub fn lower_than(v: impl Into<V>) -> Self
Set of all versions lower or equal to some version
source§impl<V: Clone> Range<V>
impl<V: Clone> Range<V>
sourcepub fn complement(&self) -> Self
pub fn complement(&self) -> Self
Returns the complement of this Range.
source§impl<V: Ord> Range<V>
impl<V: Ord> Range<V>
sourcepub fn as_singleton(&self) -> Option<&V>
pub fn as_singleton(&self) -> Option<&V>
If the range includes a single version, return it. Otherwise, returns None.
sourcepub fn bounding_range(&self) -> Option<(Bound<&V>, Bound<&V>)>
pub fn bounding_range(&self) -> Option<(Bound<&V>, Bound<&V>)>
Convert to something that can be used with BTreeMap::range. All versions contained in self, will be in the output, but there may be versions in the output that are not contained in self. Returns None if the range is empty.
sourcepub fn contains(&self, version: &V) -> bool
pub fn contains(&self, version: &V) -> bool
Returns true if this Range contains the specified value.
sourcepub fn contains_many<'s, I, BV>(
&'s self,
versions: I
) -> impl Iterator<Item = bool> + 's
pub fn contains_many<'s, I, BV>( &'s self, versions: I ) -> impl Iterator<Item = bool> + 's
Returns true if this Range contains the specified values.
The versions
iterator must be sorted.
Functionally equivalent to versions.map(|v| self.contains(v))
.
Except it runs in O(size_of_range + len_of_versions)
not O(size_of_range * len_of_versions)
sourcepub fn from_range_bounds<R, IV>(bounds: R) -> Self
pub fn from_range_bounds<R, IV>(bounds: R) -> Self
Construct a simple range from anything that impls RangeBounds like v1..v2
.
source§impl<V: Ord + Clone> Range<V>
impl<V: Ord + Clone> Range<V>
sourcepub fn intersection(&self, other: &Self) -> Self
pub fn intersection(&self, other: &Self) -> Self
Computes the intersection of two sets of versions.
sourcepub fn is_disjoint(&self, other: &Self) -> bool
pub fn is_disjoint(&self, other: &Self) -> bool
Return true if there can be no V
so that V
is contained in both self
and other
.
Note that we don’t know that set of all existing V
s here, so we only check if the segments
are disjoint, not if no version is contained in both.
sourcepub fn subset_of(&self, other: &Self) -> bool
pub fn subset_of(&self, other: &Self) -> bool
Return true if any V
that is contained in self
is also contained in other
.
Note that we don’t know that set of all existing V
s here, so we only check if all
segments self
are contained in a segment of other
.
sourcepub fn simplify<'s, I, BV>(&self, versions: I) -> Self
pub fn simplify<'s, I, BV>(&self, versions: I) -> Self
Returns a simpler Range that contains the same versions
For every one of the Versions provided in versions the existing range and the simplified range will agree on whether it is contained. The simplified version may include or exclude versions that are not in versions as the implementation wishes. For example:
- If all the versions are contained in the original than the range will be simplified to
full
. - If none of the versions are contained in the original than the range will be simplified to
empty
.
If versions are not sorted the correctness of this function is not guaranteed.
Trait Implementations§
source§impl<V: PartialEq> PartialEq for Range<V>
impl<V: PartialEq> PartialEq for Range<V>
source§impl<T: Debug + Display + Clone + Eq + Ord> VersionSet for Range<T>
impl<T: Debug + Display + Clone + Eq + Ord> VersionSet for Range<T>
source§fn complement(&self) -> Self
fn complement(&self) -> Self
source§fn intersection(&self, other: &Self) -> Self
fn intersection(&self, other: &Self) -> Self
source§fn full() -> Self
fn full() -> Self
Self::empty().complement()
.source§fn union(&self, other: &Self) -> Self
fn union(&self, other: &Self) -> Self
self.complement().intersection(&other.complement()).complement()
source§fn is_disjoint(&self, other: &Self) -> bool
fn is_disjoint(&self, other: &Self) -> bool
impl<V: Eq> Eq for Range<V>
impl<V> StructuralPartialEq for Range<V>
Auto Trait Implementations§
impl<V> Freeze for Range<V>where
V: Freeze,
impl<V> RefUnwindSafe for Range<V>where
V: RefUnwindSafe,
impl<V> Send for Range<V>where
V: Send,
impl<V> Sync for Range<V>where
V: Sync,
impl<V> Unpin for Range<V>where
V: Unpin,
impl<V> UnwindSafe for Range<V>where
V: 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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.