Skip to content

Add as_slice() to slice::IterMut and vec::Drain #58924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 9, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-Authored-By: cuviper <cuviper@gmail.com>
  • Loading branch information
Centril and cuviper authored Mar 6, 2019
commit 5384a11fcaa71d74d93f7e4ea4a2662ae28698fe
8 changes: 4 additions & 4 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3291,8 +3291,8 @@ impl<'a, T> IterMut<'a, T> {

/// Views the underlying data as a subslice of the original data.
///
/// To avoid creating `&mut` references that alias, this has a
/// borrowed lifetime from the iterator.
/// To avoid creating `&mut [T]` references that alias, the returned slice
/// borrows its lifetime from the iterator the method is applied on.
///
/// # Examples
///
Expand All @@ -3302,11 +3302,11 @@ impl<'a, T> IterMut<'a, T> {
/// # #![feature(slice_iter_mut_as_slice)]
/// // First, we declare a type which has `iter_mut` method to get the `IterMut`
/// // struct (&[usize here]):
/// let mut slice = &mut [1, 2, 3];
/// let mut slice: &mut [usize] = &mut [1, 2, 3];
///
/// // Then, we get the iterator:
/// let mut iter = slice.iter_mut();
/// // So if we print what `as_slice` method returns here, we have "[1, 2, 3]":
/// // So if we print what the `as_slice` method returns here, we have "[1, 2, 3]":
/// println!("{:?}", iter.as_slice());
/// assert_eq!(iter.as_slice(), &[1, 2, 3]);
///
Expand Down