pub struct Ranges<V> { /* private fields */ }Expand description
Ranges represents multiple intervals of a continuous range of monotone increasing values.
Implementations§
Source§impl<V> Ranges<V>
impl<V> Ranges<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> Ranges<V>
impl<V: Clone> Ranges<V>
Sourcepub fn complement(&self) -> Self
pub fn complement(&self) -> Self
Returns the complement, which contains everything not included in self.
Source§impl<V: Ord> Ranges<V>
impl<V: Ord> Ranges<V>
Sourcepub fn as_singleton(&self) -> Option<&V>
pub fn as_singleton(&self) -> Option<&V>
If self contains exactly a single version, return it, otherwise, return 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_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 self 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> Ranges<V>
impl<V: Ord + Clone> Ranges<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 Vs 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 Vs 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 representation 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.
If none of the versions are contained in the original than the range will be returned unmodified.
If the range includes a single version, it will be returned unmodified.
If all the versions are contained in the original than the range will be simplified to full.
If the given versions are not sorted the correctness of this function is not guaranteed.
Trait Implementations§
Source§impl<V: Ord> Ord for Ranges<V>
impl<V: Ord> Ord for Ranges<V>
Source§impl<V: PartialOrd> PartialOrd for Ranges<V>
impl<V: PartialOrd> PartialOrd for Ranges<V>
Source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
A simple ordering scheme where we zip the segments and compare all bounds in order. If all bounds are equal, the longer range is considered greater. (And if all zipped bounds are equal and we have the same number of segments, the ranges are equal).
impl<V: Eq> Eq for Ranges<V>
impl<V> StructuralPartialEq for Ranges<V>
Auto Trait Implementations§
impl<V> Freeze for Ranges<V>where
V: Freeze,
impl<V> RefUnwindSafe for Ranges<V>where
V: RefUnwindSafe,
impl<V> Send for Ranges<V>where
V: Send,
impl<V> Sync for Ranges<V>where
V: Sync,
impl<V> Unpin for Ranges<V>where
V: Unpin,
impl<V> UnwindSafe for Ranges<V>where
V: RefUnwindSafe + 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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)