Skip to content

Commit 71fbe52

Browse files
committed
fix: re-add union and remove early out
1 parent e72a3f5 commit 71fbe52

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/range.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,6 @@ impl<V: Ord> Range<V> {
168168

169169
/// Returns true if the this Range contains the specified value.
170170
pub fn contains(&self, v: &V) -> bool {
171-
if let Some(bounding_range) = self.bounding_range() {
172-
if !bounding_range.contains(v) {
173-
return false;
174-
}
175-
}
176-
177171
for segment in self.segments.iter() {
178172
if match segment {
179173
(Unbounded, Unbounded) => true,
@@ -230,6 +224,13 @@ fn bound_as_ref<V>(bound: &Bound<V>) -> Bound<&V> {
230224
}
231225

232226
impl<V: Ord + Clone> Range<V> {
227+
/// Computes the union of this `Range` and another.
228+
pub fn union(&self, other: &Self) -> Self {
229+
self.complement()
230+
.intersection(&other.complement())
231+
.complement()
232+
}
233+
233234
/// Computes the intersection of two sets of versions.
234235
pub fn intersection(&self, other: &Self) -> Self {
235236
let mut segments: SmallVec<Interval<V>> = SmallVec::empty();
@@ -387,6 +388,10 @@ impl<T: Debug + Display + Clone + Eq + Ord> VersionSet for Range<T> {
387388
fn full() -> Self {
388389
Range::full()
389390
}
391+
392+
fn union(&self, other: &Self) -> Self {
393+
Range::union(self, other)
394+
}
390395
}
391396

392397
// REPORT ######################################################################

0 commit comments

Comments
 (0)