| 1 |
#[allow(unused_imports)] |
| 2 |
use core::iter::{DoubleEndedIterator, ExactSizeIterator, FusedIterator}; |
| 3 |
|
| 4 |
/// A draining iterator for string data with unknown encoding. |
| 5 |
#[derive(Debug)] |
| 6 |
pub struct Drain<'a, T> { |
| 7 |
pub(crate) inner: alloc::vec::Drain<'a, T>, |
| 8 |
} |
| 9 |
|
| 10 |
impl<T> AsRef<[T]> for Drain<'_, T> { |
| 11 |
#[inline] |
| 12 |
fn as_ref(&self) -> &[T] { |
| 13 |
self.inner.as_ref() |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
impl<T> Iterator for Drain<'_, T> { |
| 18 |
type Item = T; |
| 19 |
|
| 20 |
#[inline] |
| 21 |
fn next(&mut self) -> Option<Self::Item> { |
| 22 |
self.inner.next() |
| 23 |
} |
| 24 |
|
| 25 |
#[inline] |
| 26 |
fn size_hint(&self) -> (usize, Option<usize>) { |
| 27 |
self.inner.size_hint() |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
impl<T> DoubleEndedIterator for Drain<'_, T> { |
| 32 |
#[inline] |
| 33 |
fn next_back(&mut self) -> Option<Self::Item> { |
| 34 |
self.inner.next_back() |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
impl<T> ExactSizeIterator for Drain<'_, T> { |
| 39 |
#[inline] |
| 40 |
fn len(&self) -> usize { |
| 41 |
self.inner.len() |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
impl<T> FusedIterator for Drain<'_, T> {} |