about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2017-04-23 21:14:32 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2017-05-21 01:48:03 -0700
commitf166bd9857dac3c66e812ba6bc33e59494c3fef2 (patch)
treed29f84b35bd2428ade46b8282c69f593a9f8645b /src/libcollections
parent0bd9e1f5e6e9832691d033f1cc32409f5e2a9145 (diff)
Make RangeInclusive just a two-field struct
Not being an enum improves ergonomics, especially since NonEmpty could be Empty.  It can still be iterable without an extra "done" bit by making the range have !(start <= end), which is even possible without changing the Step trait.

Implements RFC 1980
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/range.rs10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/libcollections/range.rs b/src/libcollections/range.rs
index 8f3209d015b..bc8566e8cbe 100644
--- a/src/libcollections/range.rs
+++ b/src/libcollections/range.rs
@@ -106,16 +106,10 @@ impl<T> RangeArgument<T> for Range<T> {
 #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
 impl<T> RangeArgument<T> for RangeInclusive<T> {
     fn start(&self) -> Bound<&T> {
-        match *self {
-            RangeInclusive::Empty{ ref at }            => Included(at),
-            RangeInclusive::NonEmpty { ref start, .. } => Included(start),
-        }
+        Included(&self.start)
     }
     fn end(&self) -> Bound<&T> {
-        match *self {
-            RangeInclusive::Empty{ ref at }            => Excluded(at),
-            RangeInclusive::NonEmpty { ref end, .. }   => Included(end),
-        }
+        Included(&self.end)
     }
 }