From 04d1d1b5040f007f1ea8f641dd84a95f25cd40f1 Mon Sep 17 00:00:00 2001 From: Zanie Date: Fri, 1 Dec 2023 13:28:14 -0600 Subject: [PATCH] Initial divergences from upstream (#1) --- src/range.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/range.rs b/src/range.rs index bf689c6d..41272985 100644 --- a/src/range.rs +++ b/src/range.rs @@ -218,7 +218,7 @@ impl Range { .segments .last() .expect("if there is a first element, there must be a last element"); - (start.as_ref(), end.1.as_ref()) + (bound_as_ref(start), bound_as_ref(&end.1)) }) } @@ -321,6 +321,15 @@ fn within_bounds(v: &V, segment: &Interval) -> Ordering { Ordering::Greater } +/// Implementation of [`Bound::as_ref`] which is currently marked as unstable. +fn bound_as_ref(bound: &Bound) -> Bound<&V> { + match bound { + Included(v) => Included(v), + Excluded(v) => Excluded(v), + Unbounded => Unbounded, + } +} + fn valid_segment(start: &Bound, end: &Bound) -> bool { match (start, end) { (Included(s), Included(e)) => s <= e, @@ -545,7 +554,7 @@ impl Display for Range { } else { for (idx, segment) in self.segments.iter().enumerate() { if idx > 0 { - write!(f, " | ")?; + write!(f, ", ")?; } match segment { (Unbounded, Unbounded) => write!(f, "*")?, @@ -556,7 +565,7 @@ impl Display for Range { if v == b { write!(f, "=={v}")? } else { - write!(f, ">={v}, <={b}")? + write!(f, ">={v},<={b}")? } } (Included(v), Excluded(b)) => write!(f, ">={v}, <{b}")?,