Skip to content

Commit

Permalink
stabilize vec_drain_as_slice
Browse files Browse the repository at this point in the history
  • Loading branch information
CAD97 committed May 25, 2020
1 parent a0f06d1 commit 738f848
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2747,19 +2747,25 @@ impl<'a, T> Drain<'a, T> {
/// # Examples
///
/// ```
/// # #![feature(vec_drain_as_slice)]
/// let mut vec = vec!['a', 'b', 'c'];
/// let mut drain = vec.drain(..);
/// assert_eq!(drain.as_slice(), &['a', 'b', 'c']);
/// let _ = drain.next().unwrap();
/// assert_eq!(drain.as_slice(), &['b', 'c']);
/// ```
#[unstable(feature = "vec_drain_as_slice", reason = "recently added", issue = "58957")]
#[stable(feature = "vec_drain_as_slice", since = "1.46.0")]
pub fn as_slice(&self) -> &[T] {
self.iter.as_slice()
}
}

#[stable(feature = "vec_drain_as_slice", since = "1.46.0")]
impl<'a, T> AsRef<[T]> for Drain<'a, T> {
fn as_ref(&self) -> &[T] {
self.as_slice()
}
}

#[stable(feature = "drain", since = "1.6.0")]
unsafe impl<T: Sync> Sync for Drain<'_, T> {}
#[stable(feature = "drain", since = "1.6.0")]
Expand Down

0 comments on commit 738f848

Please sign in to comment.