From 8e58043caa79c084661306a8f604c452560d3539 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Mon, 14 Dec 2020 06:39:33 -0800 Subject: [PATCH] impl AsMut<[T]> for vec::IntoIter Adds `impl AsMut<[T]> for vec::IntoIter`, exposing the same behavior as `vec::IntoIter::as_mut_slice`, which has been stable since 1.15.0. https://doc.rust-lang.org/std/vec/struct.IntoIter.html#method.as_mut_slice See rust-lang/rust#72583, which added the `AsRef<[T]>` impl to `vec::IntoIter`. Adding this symmetric API. As a trait impl, this will be insta-stable. --- library/alloc/src/vec.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index c86798a1bd3a5..b3af0b1d8b6ad 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -2665,6 +2665,13 @@ impl AsRef<[T]> for IntoIter { } } +#[stable(feature = "vec_intoiter_as_mut", since = "1.50.0")] +impl AsMut<[T]> for IntoIter { + fn as_mut(&mut self) -> &mut [T] { + self.as_mut_slice() + } +} + #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Send for IntoIter {} #[stable(feature = "rust1", since = "1.0.0")]