Skip to content

Commit

Permalink
slice: Stabilize IterMut::as_slice.
Browse files Browse the repository at this point in the history
Much like #72584.

As per #58957 there's no blocker for this, and I wanted to use this
today :-)
  • Loading branch information
emilio committed Mar 4, 2021
1 parent ec7f258 commit 5176f67
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions library/core/src/slice/iter.rs
Expand Up @@ -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:
Expand All @@ -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.52.0")]
pub fn as_slice(&self) -> &[T] {
self.make_slice()
}
}

#[stable(feature = "slice_iter_mut_as_slice", since = "1.52.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
Expand Down

0 comments on commit 5176f67

Please sign in to comment.