diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2015-01-28 17:06:46 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2015-01-30 12:01:08 +1300 |
| commit | bf2b4738163b196685198e91d7ce4e2761bb718e (patch) | |
| tree | 84d15b7a762f4b8ef5517d05b5963a448e4d8414 /src/libcore | |
| parent | c64a96d385fb3b23c6744cf8d927c9c175936b5f (diff) | |
| download | rust-bf2b4738163b196685198e91d7ce4e2761bb718e.tar.gz rust-bf2b4738163b196685198e91d7ce4e2761bb718e.zip | |
Rename FullRange to RangeFull
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/ops.rs | 17 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 42 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 10 |
3 files changed, 55 insertions, 14 deletions
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 55ff3eb4d06..9e020eeb8a9 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -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"] diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index b1e9084d210..40e66db3ae5 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -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) } } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 22851965644..8495a03747e 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -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 |
