diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-27 10:07:44 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-27 10:07:44 -0700 |
| commit | 4bd15522968c467d41fd843534b10a02ba44ccea (patch) | |
| tree | af1abb9e16df8b27e903fcb268150df67da631a9 /src/libcollections | |
| parent | 8eb918e9701f927fde42d0f2ea0ab4438bbd6c79 (diff) | |
| parent | c5b876375312410c6e0df6e72155c8d0fac62c2c (diff) | |
| download | rust-4bd15522968c467d41fd843534b10a02ba44ccea.tar.gz rust-4bd15522968c467d41fd843534b10a02ba44ccea.zip | |
rollup merge of #23721: erickt/deprecate
This is technically a breaking change as it deprecates and unstables some previously stable apis that were missed in the last round of deprecations. [breaking change]
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/slice.rs | 8 | ||||
| -rw-r--r-- | src/libcollections/vec.rs | 49 |
2 files changed, 23 insertions, 34 deletions
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 688d730e252..83e632e6c96 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -611,9 +611,11 @@ impl<T> [T] { core_slice::SliceExt::get_mut(self, index) } - /// Work with `self` as a mut slice. - /// Primarily intended for getting a &mut [T] from a [T; N]. - #[stable(feature = "rust1", since = "1.0.0")] + /// Deprecated: use `&mut s[..]` instead. + #[unstable(feature = "collections", + reason = "will be replaced by slice syntax")] + #[deprecated(since = "1.0.0", reason = "use &mut s[..] instead")] + #[allow(deprecated)] pub fn as_mut_slice(&mut self) -> &mut [T] { core_slice::SliceExt::as_mut_slice(self) } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index cf0163f3ef4..95cb949ae6c 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -423,24 +423,13 @@ impl<T> Vec<T> { } } - /// Returns a mutable slice of the elements of `self`. - /// - /// # Examples - /// - /// ``` - /// fn foo(slice: &mut [i32]) {} - /// - /// let mut vec = vec![1, 2]; - /// foo(vec.as_mut_slice()); - /// ``` + /// Deprecated: use `&mut s[..]` instead. #[inline] - #[stable(feature = "rust1", since = "1.0.0")] + #[unstable(feature = "collections", + reason = "will be replaced by slice syntax")] + #[deprecated(since = "1.0.0", reason = "use &mut s[..] instead")] pub fn as_mut_slice(&mut self) -> &mut [T] { - unsafe { - let ptr = *self.ptr; - assume(!ptr.is_null()); - slice::from_raw_parts_mut(ptr, self.len) - } + &mut self[..] } /// Creates a consuming iterator, that is, one that moves each value out of @@ -1494,13 +1483,13 @@ impl<T> ops::IndexMut<ops::RangeFull> for Vec<T> { #[cfg(stage0)] #[inline] fn index_mut(&mut self, _index: &ops::RangeFull) -> &mut [T] { - self.as_mut_slice() + self } #[cfg(not(stage0))] #[inline] fn index_mut(&mut self, _index: ops::RangeFull) -> &mut [T] { - self.as_mut_slice() + self } } @@ -1519,7 +1508,13 @@ impl<T> ops::Deref for Vec<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T> ops::DerefMut for Vec<T> { - fn deref_mut(&mut self) -> &mut [T] { self.as_mut_slice() } + fn deref_mut(&mut self) -> &mut [T] { + unsafe { + let ptr = *self.ptr; + assume(!ptr.is_null()); + slice::from_raw_parts_mut(ptr, self.len) + } + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1656,21 +1651,13 @@ impl<T: Ord> Ord for Vec<T> { } } +#[unstable(feature = "collections", + reason = "will be replaced by slice syntax")] +#[deprecated(since = "1.0.0", reason = "use &mut s[..] instead")] #[allow(deprecated)] impl<T> AsSlice<T> for Vec<T> { - /// Returns a slice into `self`. - /// - /// # Examples - /// - /// ``` - /// # #![feature(core)] - /// fn foo(slice: &[i32]) {} - /// - /// let vec = vec![1, 2]; - /// foo(vec.as_slice()); - /// ``` + /// Deprecated: use `&mut s[..]` instead. #[inline] - #[stable(feature = "rust1", since = "1.0.0")] fn as_slice(&self) -> &[T] { self } |
