about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Burka <aburka@seas.upenn.edu>2016-01-13 13:12:16 -0500
committerAlex Burka <aburka@seas.upenn.edu>2016-02-27 02:01:41 -0500
commit24cc90262bd5ec52aa421103ef7c89a0697b046d (patch)
tree8184668622741faa62a24660cf57433ab81a8337
parent15a8a296b724599a1eda807c3057338b11cb94bf (diff)
downloadrust-24cc90262bd5ec52aa421103ef7c89a0697b046d.tar.gz
rust-24cc90262bd5ec52aa421103ef7c89a0697b046d.zip
note work still to be done
In particular, uses of inclusive ranges within the standard library are
still waiting. Slices and collections can be sliced with `usize` and
`Range*<usize>`, but not yet `Range*Inclusive<usize>`.

Also, we need to figure out what to do about `RangeArgument`. Currently
it has `start()` and `end()` methods which are pretty much identical to
`Range::start` and `Range::end`. For the same reason as Range itself,
these methods can't express a range such as `0...255u8` without
overflow. The easiest choice, it seems to me, is either changing the
meaning of `end()` to be inclusive, or adding a new method, say
`last()`, that is inclusive and specifying that `end()` returns `None`
in cases where it would overflow. Changing the semantics would be a
breaking change, but `RangeArgument` is unstable so maybe we should do
it anyway.
-rw-r--r--src/libcollections/range.rs1
-rw-r--r--src/libcore/iter.rs4
-rw-r--r--src/libcore/ops.rs12
-rw-r--r--src/libcore/slice.rs2
4 files changed, 13 insertions, 6 deletions
diff --git a/src/libcollections/range.rs b/src/libcollections/range.rs
index afcd779ddf1..4e39191b472 100644
--- a/src/libcollections/range.rs
+++ b/src/libcollections/range.rs
@@ -35,6 +35,7 @@ pub trait RangeArgument<T> {
     }
 }
 
+// FIXME add inclusive ranges to RangeArgument
 
 impl<T> RangeArgument<T> for RangeFull {}
 
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 1f5ef6be0bc..305f32e2637 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -4417,7 +4417,9 @@ macro_rules! range_exact_iter_impl {
         #[stable(feature = "rust1", since = "1.0.0")]
         impl ExactSizeIterator for ops::Range<$t> { }
 
-        #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
+        #[unstable(feature = "inclusive_range",
+                   reason = "recently added, follows RFC",
+                   issue = "28237")]
         impl ExactSizeIterator for ops::RangeInclusive<$t> { }
     )*)
 }
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs
index b5bec316947..e5a51c98aca 100644
--- a/src/libcore/ops.rs
+++ b/src/libcore/ops.rs
@@ -1468,7 +1468,7 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
 
 /// An unbounded range.
 #[derive(Copy, Clone, PartialEq, Eq)]
-#[cfg_attr(stage0, lang = "range_full")] // TODO remove attribute after next snapshot
+#[cfg_attr(stage0, lang = "range_full")] // FIXME remove attribute after next snapshot
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct RangeFull;
 
@@ -1481,7 +1481,7 @@ impl fmt::Debug for RangeFull {
 
 /// A (half-open) range which is bounded at both ends.
 #[derive(Clone, PartialEq, Eq)]
-#[cfg_attr(stage0, lang = "range")] // TODO remove attribute after next snapshot
+#[cfg_attr(stage0, lang = "range")] // FIXME remove attribute after next snapshot
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct Range<Idx> {
     /// The lower bound of the range (inclusive).
@@ -1501,7 +1501,7 @@ impl<Idx: fmt::Debug> fmt::Debug for Range<Idx> {
 
 /// A range which is only bounded below.
 #[derive(Clone, PartialEq, Eq)]
-#[cfg_attr(stage0, lang = "range_from")] // TODO remove attribute after next snapshot
+#[cfg_attr(stage0, lang = "range_from")] // FIXME remove attribute after next snapshot
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct RangeFrom<Idx> {
     /// The lower bound of the range (inclusive).
@@ -1518,7 +1518,7 @@ impl<Idx: fmt::Debug> fmt::Debug for RangeFrom<Idx> {
 
 /// A range which is only bounded above.
 #[derive(Copy, Clone, PartialEq, Eq)]
-#[cfg_attr(stage0, lang = "range_to")] // TODO remove attribute after next snapshot
+#[cfg_attr(stage0, lang = "range_to")] // FIXME remove attribute after next snapshot
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct RangeTo<Idx> {
     /// The upper bound of the range (exclusive).
@@ -1586,7 +1586,9 @@ impl<Idx: PartialOrd + One + Sub<Output=Idx>> From<Range<Idx>> for RangeInclusiv
 #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
 pub struct RangeToInclusive<Idx> {
     /// The upper bound of the range (inclusive)
-    #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
+    #[unstable(feature = "inclusive_range",
+               reason = "recently added, follows RFC",
+               issue = "28237")]
     pub end: Idx,
 }
 
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs
index afda70f4fcc..73466a849dc 100644
--- a/src/libcore/slice.rs
+++ b/src/libcore/slice.rs
@@ -533,6 +533,8 @@ fn slice_index_order_fail(index: usize, end: usize) -> ! {
     panic!("slice index starts at {} but ends at {}", index, end);
 }
 
+// FIXME implement indexing with inclusive ranges
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::Index<ops::Range<usize>> for [T] {
     type Output = [T];