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 committed Dec 1, 2023
1 parent fddca1e commit a1d584a
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 @@ -200,7 +200,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 @@ -303,15 +303,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 @@ -518,7 +509,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 @@ -529,7 +520,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 a1d584a

Please sign in to comment.