Skip to content

Commit 3a75e11

Browse files
clarfontheybluss
authored andcommitted
Add as_slice & as_mut_slice methods to IntoIter
1 parent f243d43 commit 3a75e11

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/arrayvec.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,17 @@ pub struct IntoIter<T, const CAP: usize> {
880880
index: usize,
881881
v: ArrayVec<T, CAP>,
882882
}
883+
impl<T, const CAP: usize> IntoIter<T, CAP> {
884+
/// Returns the remaining items of this iterator as a slice.
885+
pub fn as_slice(&self) -> &[T] {
886+
&self.v[self.index..]
887+
}
888+
889+
/// Returns the remaining items of this iterator as a mutable slice.
890+
pub fn as_mut_slice(&mut self) -> &mut [T] {
891+
&mut self.v[self.index..]
892+
}
893+
}
883894

884895
impl<T, const CAP: usize> Iterator for IntoIter<T, CAP> {
885896
type Item = T;

0 commit comments

Comments
 (0)