about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorMark Simulacrum <mark.simulacrum@gmail.com>2017-05-24 19:50:01 -0600
committerGitHub <noreply@github.com>2017-05-24 19:50:01 -0600
commit00c87a6486428b072199809b051beea1124f616f (patch)
treebf99a9d33045f51496702bbf61788d8e4adf6b68 /src/libcollections
parent989c8e86e16ddfa146cd3ba2557d9becb2841a89 (diff)
parent7eaca60f3b3b783ffa1e80ccf91e820f9436b3a3 (diff)
Rollup merge of #42134 - scottmcm:rangeinclusive-struct, r=aturon
Make RangeInclusive just a two-field struct

Not being an enum improves ergonomics and consistency, especially since NonEmpty variant wasn't prevented from being 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 merged https://github.com/rust-lang/rfcs/pull/1980; tracking issue https://github.com/rust-lang/rust/issues/28237.

This is definitely a breaking change to anything consuming `RangeInclusive` directly (not as an Iterator) or constructing it without using the sugar.  Is there some change that would make sense before this so compilation failures could be compatibly fixed ahead of time?

r? @aturon (as FCP proposer on the RFC)
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)
     }
 }