Skip to content

Commit

Permalink
Add as_slice & as_mut_slice methods to IntoIter
Browse files Browse the repository at this point in the history
  • Loading branch information
clarfonthey authored and bluss committed Mar 26, 2024
1 parent f243d43 commit 3a75e11
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/arrayvec.rs
Expand Up @@ -880,6 +880,17 @@ pub struct IntoIter<T, const CAP: usize> {
index: usize,
v: ArrayVec<T, CAP>,
}
impl<T, const CAP: usize> IntoIter<T, CAP> {
/// 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<T, const CAP: usize> Iterator for IntoIter<T, CAP> {
type Item = T;
Expand Down

0 comments on commit 3a75e11

Please sign in to comment.