extern crate alloc;
use core::{borrow::Borrow, iter::FusedIterator};
pub struct IntoIter<K>(alloc::vec::IntoIter<K>);
impl<K> Iterator for IntoIter<K> {
type Item = K;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.0.next()
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
#[inline]
fn count(self) -> usize {
self.0.count()
}
}
impl<K> FusedIterator for IntoIter<K> {}
impl<K> ExactSizeIterator for IntoIter<K> {}
impl<K> DoubleEndedIterator for IntoIter<K> {
#[inline]
fn next_back(&mut self) -> Option<Self::Item> {
self.0.next_back()
}
}
pub struct Iter<'a, K>(pub(super) core::slice::Iter<'a, K>);
impl<'a, K> Iterator for Iter<'a, K> {
type Item = &'a K;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.0.next()
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
#[inline]
fn count(self) -> usize {
self.0.count()
}
}
impl<K> FusedIterator for Iter<'_, K> {}
impl<K> ExactSizeIterator for Iter<'_, K> {}
impl<K> DoubleEndedIterator for Iter<'_, K> {
#[inline]
fn next_back(&mut self) -> Option<Self::Item> {
self.0.next_back()
}
}
pub struct Drain<'a, K>(pub(super) alloc::vec::Drain<'a, K>);
impl<K> Iterator for Drain<'_, K> {
type Item = K;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.0.next()
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
#[inline]
fn count(self) -> usize {
self.0.count()
}
}
impl<K> FusedIterator for Drain<'_, K> {}
impl<K> ExactSizeIterator for Drain<'_, K> {}
impl<K> DoubleEndedIterator for Drain<'_, K> {
#[inline]
fn next_back(&mut self) -> Option<Self::Item> {
self.0.next_back()
}
}
impl<K: Borrow<str>> IntoIterator for super::PrefixArraySet<K> {
type Item = K;
type IntoIter = IntoIter<K>;
fn into_iter(self) -> Self::IntoIter {
IntoIter(self.0.into_iter())
}
}
impl<'a, K: Borrow<str>> IntoIterator for &'a super::PrefixArraySet<K> {
type Item = &'a K;
type IntoIter = Iter<'a, K>;
fn into_iter(self) -> Self::IntoIter {
Iter(self.0.iter())
}
}
impl<'a, K: Borrow<str>> IntoIterator for &'a super::SetSubSlice<K> {
type Item = &'a K;
type IntoIter = Iter<'a, K>;
fn into_iter(self) -> Self::IntoIter {
Iter(self.0.iter())
}
}
impl<K: Borrow<str>> core::iter::FromIterator<K> for super::PrefixArraySet<K> {
fn from_iter<T: IntoIterator<Item = K>>(iter: T) -> Self {
Self::from_vec_lossy(iter.into_iter().collect())
}
}