diff options
| author | Aaron Turon <aturon@mozilla.com> | 2015-01-17 16:15:47 -0800 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2015-01-21 07:45:45 -0800 |
| commit | 092ba6a8563b5c95f5aa53a705eaba6cc94e2da7 (patch) | |
| tree | 17deb06bc801ba7201beeaa337716fbae6279195 /src/libcollections/slice.rs | |
| parent | fba0bf63a90379e8825012a817167774e14a627f (diff) | |
| download | rust-092ba6a8563b5c95f5aa53a705eaba6cc94e2da7.tar.gz rust-092ba6a8563b5c95f5aa53a705eaba6cc94e2da7.zip | |
Deprecate slicing methods in favor of notation
This commit deprecates `slice`, `slice_from`, `slice_to` and their mutable variants in favor of slice notation. The `as_slice` methods are left intact, for now. [breaking-change]
Diffstat (limited to 'src/libcollections/slice.rs')
| -rw-r--r-- | src/libcollections/slice.rs | 62 |
1 files changed, 18 insertions, 44 deletions
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 988ec4c661f..a640e4ee0e3 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -169,29 +169,16 @@ pub trait SliceExt { #[unstable = "uncertain about this API approach"] fn move_from(&mut self, src: Vec<Self::Item>, start: uint, end: uint) -> uint; - /// Returns a subslice spanning the interval [`start`, `end`). - /// - /// Panics when the end of the new slice lies beyond the end of the - /// original slice (i.e. when `end > self.len()`) or when `start > end`. - /// - /// Slicing with `start` equal to `end` yields an empty slice. - #[unstable = "will be replaced by slice syntax"] + /// Deprecated: use `&s[start .. end]` notation instead. + #[deprecated = "use &s[start .. end] instead"] fn slice(&self, start: uint, end: uint) -> &[Self::Item]; - /// Returns a subslice from `start` to the end of the slice. - /// - /// Panics when `start` is strictly greater than the length of the original slice. - /// - /// Slicing from `self.len()` yields an empty slice. - #[unstable = "will be replaced by slice syntax"] + /// Deprecated: use `&s[start..]` notation instead. + #[deprecated = "use &s[start..] isntead"] fn slice_from(&self, start: uint) -> &[Self::Item]; - /// Returns a subslice from the start of the slice to `end`. - /// - /// Panics when `end` is strictly greater than the length of the original slice. - /// - /// Slicing to `0` yields an empty slice. - #[unstable = "will be replaced by slice syntax"] + /// Deprecated: use `&s[..end]` notation instead. + #[deprecated = "use &s[..end] instead"] fn slice_to(&self, end: uint) -> &[Self::Item]; /// Divides one slice into two at an index. @@ -378,29 +365,16 @@ pub trait SliceExt { #[stable] fn as_mut_slice(&mut self) -> &mut [Self::Item]; - /// Returns a mutable subslice spanning the interval [`start`, `end`). - /// - /// Panics when the end of the new slice lies beyond the end of the - /// original slice (i.e. when `end > self.len()`) or when `start > end`. - /// - /// Slicing with `start` equal to `end` yields an empty slice. - #[unstable = "will be replaced by slice syntax"] + /// Deprecated: use `&mut s[start .. end]` instead. + #[deprecated = "use &mut s[start .. end] instead"] fn slice_mut(&mut self, start: uint, end: uint) -> &mut [Self::Item]; - /// Returns a mutable subslice from `start` to the end of the slice. - /// - /// Panics when `start` is strictly greater than the length of the original slice. - /// - /// Slicing from `self.len()` yields an empty slice. - #[unstable = "will be replaced by slice syntax"] + /// Deprecated: use `&mut s[start ..]` instead. + #[deprecated = "use &mut s[start ..] instead"] fn slice_from_mut(&mut self, start: uint) -> &mut [Self::Item]; - /// Returns a mutable subslice from the start of the slice to `end`. - /// - /// Panics when `end` is strictly greater than the length of the original slice. - /// - /// Slicing to `0` yields an empty slice. - #[unstable = "will be replaced by slice syntax"] + /// Deprecated: use `&mut s[.. end]` instead. + #[deprecated = "use &mut s[.. end] instead"] fn slice_to_mut(&mut self, end: uint) -> &mut [Self::Item]; /// Returns an iterator that allows modifying each value @@ -720,17 +694,17 @@ impl<T> SliceExt for [T] { #[inline] fn slice<'a>(&'a self, start: uint, end: uint) -> &'a [T] { - core_slice::SliceExt::slice(self, start, end) + &self[start .. end] } #[inline] fn slice_from<'a>(&'a self, start: uint) -> &'a [T] { - core_slice::SliceExt::slice_from(self, start) + &self[start ..] } #[inline] fn slice_to<'a>(&'a self, end: uint) -> &'a [T] { - core_slice::SliceExt::slice_to(self, end) + &self[.. end] } #[inline] @@ -834,17 +808,17 @@ impl<T> SliceExt for [T] { #[inline] fn slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] { - core_slice::SliceExt::slice_mut(self, start, end) + &mut self[start .. end] } #[inline] fn slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T] { - core_slice::SliceExt::slice_from_mut(self, start) + &mut self[start ..] } #[inline] fn slice_to_mut<'a>(&'a mut self, end: uint) -> &'a mut [T] { - core_slice::SliceExt::slice_to_mut(self, end) + &mut self[.. end] } #[inline] |
