From a2151d91223138e39e3b9e323d35321ba27f7919 Mon Sep 17 00:00:00 2001 From: Zanie Date: Fri, 1 Dec 2023 13:28:26 -0600 Subject: [PATCH] Update `Range` to match upstream (#5) --- src/range.rs | 16 +++------------- tests/examples.rs | 4 ++-- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/range.rs b/src/range.rs index 4d2f13b5..8bef6523 100644 --- a/src/range.rs +++ b/src/range.rs @@ -217,7 +217,7 @@ impl Range { .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()) }) } @@ -334,16 +334,6 @@ fn within_bounds(version: &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, - } -} - -/// A valid segment is one where at least one version fits between start and end fn valid_segment(start: &Bound, end: &Bound) -> bool { match (start, end) { // Singleton interval are allowed @@ -737,7 +727,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, "*")?, @@ -748,7 +738,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}")?, diff --git a/tests/examples.rs b/tests/examples.rs index 806a332d..db0d3258 100644 --- a/tests/examples.rs +++ b/tests/examples.rs @@ -231,8 +231,8 @@ fn confusing_with_lots_of_holes() { }; assert_eq!( &DefaultStringReporter::report(&derivation_tree), - r#"Because there is no available version for bar and foo ==1, ==2, ==3, ==4, ==5 depends on bar, foo ==1, ==2, ==3, ==4, ==5 is forbidden. -And because there is no version of foo in <1, >1, <2, >2, <3, >3, <4, >4, <5, >5 and root ==1 depends on foo, root ==1 is forbidden."# + r#"Because there is no available version for bar and foo ==1 | ==2 | ==3 | ==4 | ==5 depends on bar, foo ==1 | ==2 | ==3 | ==4 | ==5 is forbidden. +And because there is no version of foo in <1 | >1, <2 | >2, <3 | >3, <4 | >4, <5 | >5 and root ==1 depends on foo, root ==1 is forbidden."# ); derivation_tree.collapse_no_versions(); assert_eq!(