Skip to content

Commit

Permalink
Update Range to match upstream (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored and konstin committed Mar 6, 2024
1 parent e2e27f1 commit 21b89d7
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<V: Ord> Range<V> {
.segments
.last()
.expect("if there is a first element, there must be a last element");
(bound_as_ref(start), bound_as_ref(&end.1))
(start.as_ref(), end.1.as_ref())
})
}

Expand Down Expand Up @@ -320,15 +320,6 @@ fn within_bounds<V: PartialOrd>(v: &V, segment: &Interval<V>) -> Ordering {
Ordering::Greater
}

/// Implementation of [`Bound::as_ref`] which is currently marked as unstable.
fn bound_as_ref<V>(bound: &Bound<V>) -> Bound<&V> {
match bound {
Included(v) => Included(v),
Excluded(v) => Excluded(v),
Unbounded => Unbounded,
}
}

fn valid_segment<T: PartialOrd>(start: &Bound<T>, end: &Bound<T>) -> bool {
match (start, end) {
(Included(s), Included(e)) => s <= e,
Expand Down Expand Up @@ -550,7 +541,7 @@ impl<V: Display + Eq> Display for Range<V> {
} else {
for (idx, segment) in self.segments.iter().enumerate() {
if idx > 0 {
write!(f, ", ")?;
write!(f, " | ")?;
}
match segment {
(Unbounded, Unbounded) => write!(f, "*")?,
Expand All @@ -561,7 +552,7 @@ impl<V: Display + Eq> Display for Range<V> {
if v == b {
write!(f, "=={v}")?
} else {
write!(f, ">={v},<={b}")?
write!(f, ">={v}, <={b}")?
}
}
(Included(v), Excluded(b)) => write!(f, ">={v}, <{b}")?,
Expand Down

0 comments on commit 21b89d7

Please sign in to comment.