use super::Set;
use core::iter::FusedIterator;
#[repr(transparent)]
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct Drain<'a, T> {
iter: crate::map::drain::Drain<'a, T, ()>,
}
impl<T, const N: usize> Set<T, N> {
pub fn drain(&mut self) -> Drain<'_, T> {
Drain {
iter: self.map.drain(),
}
}
}
impl<K> Iterator for Drain<'_, K> {
type Item = K;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.iter.next().map(|(k, ())| k)
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
(self.iter.len(), Some(self.iter.len()))
}
}
impl<K> ExactSizeIterator for Drain<'_, K> {
#[inline]
fn len(&self) -> usize {
self.iter.len()
}
}
impl<K> FusedIterator for Drain<'_, K> {}