From 3a75e11edc337e5807e46cfeb7ab6b941c9e31b5 Mon Sep 17 00:00:00 2001 From: ltdk Date: Wed, 3 Aug 2022 00:29:01 -0400 Subject: [PATCH] Add as_slice & as_mut_slice methods to IntoIter --- src/arrayvec.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/arrayvec.rs b/src/arrayvec.rs index 893028b..e87b3ef 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -880,6 +880,17 @@ pub struct IntoIter { index: usize, v: ArrayVec, } +impl IntoIter { + /// Returns the remaining items of this iterator as a slice. + pub fn as_slice(&self) -> &[T] { + &self.v[self.index..] + } + + /// Returns the remaining items of this iterator as a mutable slice. + pub fn as_mut_slice(&mut self) -> &mut [T] { + &mut self.v[self.index..] + } +} impl Iterator for IntoIter { type Item = T;