Rename FullRange to RangeFull

This commit is contained in:
Nick Cameron 2015-01-28 17:06:46 +13:00
parent c64a96d385
commit bf2b473816
17 changed files with 134 additions and 31 deletions

View file

@ -947,11 +947,20 @@ pub trait IndexMut<Index: ?Sized> {
}
/// An unbounded range.
#[cfg(stage0)]
#[derive(Copy, Clone, PartialEq, Eq)]
#[lang="full_range"]
#[unstable(feature = "core", reason = "may be renamed to RangeFull")]
pub struct FullRange;
/// An unbounded range.
#[cfg(not(stage0))]
#[derive(Copy, Clone, PartialEq, Eq)]
#[lang="range_full"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RangeFull;
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for FullRange {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
@ -959,6 +968,14 @@ impl fmt::Debug for FullRange {
}
}
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for RangeFull {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt("..", fmt)
}
}
/// A (half-open) range which is bounded at both ends.
#[derive(Copy, Clone, PartialEq, Eq)]
#[lang="range"]

View file

@ -44,6 +44,10 @@ use iter::*;
use marker::Copy;
use num::Int;
use ops::{FnMut, self, Index};
#[cfg(stage0)]
use ops::FullRange as RangeFull;
#[cfg(not(stage0))]
use ops::RangeFull;
use option::Option;
use option::Option::{None, Some};
use result::Result;
@ -543,10 +547,10 @@ impl<T> ops::Index<ops::RangeFrom<uint>> for [T] {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ops::Index<ops::FullRange> for [T] {
impl<T> ops::Index<RangeFull> for [T] {
type Output = [T];
#[inline]
fn index(&self, _index: &ops::FullRange) -> &[T] {
fn index(&self, _index: &RangeFull) -> &[T] {
self
}
}
@ -584,10 +588,10 @@ impl<T> ops::IndexMut<ops::RangeFrom<uint>> for [T] {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ops::IndexMut<ops::FullRange> for [T] {
impl<T> ops::IndexMut<RangeFull> for [T] {
type Output = [T];
#[inline]
fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
fn index_mut(&mut self, _index: &RangeFull) -> &mut [T] {
self
}
}
@ -750,6 +754,7 @@ impl<'a, T> ops::Index<ops::RangeFrom<uint>> for Iter<'a, T> {
}
}
#[cfg(stage0)]
#[unstable(feature = "core")]
impl<'a, T> ops::Index<ops::FullRange> for Iter<'a, T> {
type Output = [T];
@ -758,6 +763,15 @@ impl<'a, T> ops::Index<ops::FullRange> for Iter<'a, T> {
self.as_slice()
}
}
#[cfg(not(stage0))]
#[unstable(feature = "core")]
impl<'a, T> ops::Index<RangeFull> for Iter<'a, T> {
type Output = [T];
#[inline]
fn index(&self, _index: &RangeFull) -> &[T] {
self.as_slice()
}
}
impl<'a, T> Iter<'a, T> {
/// View the underlying data as a subslice of the original data.
@ -821,7 +835,7 @@ impl<'a, T> ops::Index<ops::Range<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
fn index(&self, index: &ops::Range<uint>) -> &[T] {
self.index(&ops::FullRange).index(index)
self.index(&RangeFull).index(index)
}
}
#[unstable(feature = "core")]
@ -829,7 +843,7 @@ impl<'a, T> ops::Index<ops::RangeTo<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
fn index(&self, index: &ops::RangeTo<uint>) -> &[T] {
self.index(&ops::FullRange).index(index)
self.index(&RangeFull).index(index)
}
}
#[unstable(feature = "core")]
@ -837,14 +851,14 @@ impl<'a, T> ops::Index<ops::RangeFrom<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
self.index(&ops::FullRange).index(index)
self.index(&RangeFull).index(index)
}
}
#[unstable(feature = "core")]
impl<'a, T> ops::Index<ops::FullRange> for IterMut<'a, T> {
impl<'a, T> ops::Index<RangeFull> for IterMut<'a, T> {
type Output = [T];
#[inline]
fn index(&self, _index: &ops::FullRange) -> &[T] {
fn index(&self, _index: &RangeFull) -> &[T] {
make_slice!(T => &[T]: self.ptr, self.end)
}
}
@ -854,7 +868,7 @@ impl<'a, T> ops::IndexMut<ops::Range<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
fn index_mut(&mut self, index: &ops::Range<uint>) -> &mut [T] {
self.index_mut(&ops::FullRange).index_mut(index)
self.index_mut(&RangeFull).index_mut(index)
}
}
#[unstable(feature = "core")]
@ -862,7 +876,7 @@ impl<'a, T> ops::IndexMut<ops::RangeTo<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
fn index_mut(&mut self, index: &ops::RangeTo<uint>) -> &mut [T] {
self.index_mut(&ops::FullRange).index_mut(index)
self.index_mut(&RangeFull).index_mut(index)
}
}
#[unstable(feature = "core")]
@ -870,14 +884,14 @@ impl<'a, T> ops::IndexMut<ops::RangeFrom<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
self.index_mut(&ops::FullRange).index_mut(index)
self.index_mut(&RangeFull).index_mut(index)
}
}
#[unstable(feature = "core")]
impl<'a, T> ops::IndexMut<ops::FullRange> for IterMut<'a, T> {
impl<'a, T> ops::IndexMut<RangeFull> for IterMut<'a, T> {
type Output = [T];
#[inline]
fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
fn index_mut(&mut self, _index: &RangeFull) -> &mut [T] {
make_slice!(T => &mut [T]: self.ptr, self.end)
}
}

View file

@ -1249,6 +1249,7 @@ mod traits {
}
}
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl ops::Index<ops::FullRange> for str {
type Output = str;
@ -1257,6 +1258,15 @@ mod traits {
self
}
}
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl ops::Index<ops::RangeFull> for str {
type Output = str;
#[inline]
fn index(&self, _index: &ops::RangeFull) -> &str {
self
}
}
}
/// Any string that can be represented as a slice