about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-03-22 02:20:30 +0100
committerGitHub <noreply@github.com>2021-03-22 02:20:30 +0100
commit34285def872a2a797514fe72308eee383a583cc8 (patch)
treeadc318a774fc6db1ad74d32071906d0eb2610cf3
parentc66d66e8d1212b4f2f19a6805e05e24b34f4bdae (diff)
parent2bd7c1b5de8bdbc7cafa2ee496ef9d80381fb0dd (diff)
downloadrust-34285def872a2a797514fe72308eee383a583cc8.tar.gz
rust-34285def872a2a797514fe72308eee383a583cc8.zip
Rollup merge of #82771 - emilio:iter-mut-as-slice, r=m-ou-se
slice: Stabilize IterMut::as_slice.

Much like #72584.

As per #58957 there's no blocker for this, and I wanted to use this
today :-)

Closes #58957
-rw-r--r--library/core/src/slice/iter.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs
index c82b76df6ff..1ee662c6c8e 100644
--- a/library/core/src/slice/iter.rs
+++ b/library/core/src/slice/iter.rs
@@ -286,7 +286,6 @@ impl<'a, T> IterMut<'a, T> {
     /// Basic usage:
     ///
     /// ```
-    /// # #![feature(slice_iter_mut_as_slice)]
     /// let mut slice: &mut [usize] = &mut [1, 2, 3];
     ///
     /// // First, we get the iterator:
@@ -299,12 +298,19 @@ impl<'a, T> IterMut<'a, T> {
     /// // Now `as_slice` returns "[2, 3]":
     /// assert_eq!(iter.as_slice(), &[2, 3]);
     /// ```
-    #[unstable(feature = "slice_iter_mut_as_slice", reason = "recently added", issue = "58957")]
+    #[stable(feature = "slice_iter_mut_as_slice", since = "1.53.0")]
     pub fn as_slice(&self) -> &[T] {
         self.make_slice()
     }
 }
 
+#[stable(feature = "slice_iter_mut_as_slice", since = "1.53.0")]
+impl<T> AsRef<[T]> for IterMut<'_, T> {
+    fn as_ref(&self) -> &[T] {
+        self.as_slice()
+    }
+}
+
 iterator! {struct IterMut -> *mut T, &'a mut T, mut, {mut}, {}}
 
 /// An internal abstraction over the splitting iterators, so that