arrayset 3.1.1

An array-backed ordered set type.
Documentation
use core::{iter::FusedIterator, slice};

#[derive(Clone, Debug)]
pub struct Keys<'a, K>(slice::Iter<'a, K>);

impl<'a, K> Keys<'a, K>
where
    K: 'a,
{
    pub(super) fn new(keys: &'a [K]) -> Self {
        Self(keys.iter())
    }
}

impl<'a, K> Iterator for Keys<'a, K>
where
    K: 'a,
{
    type Item = &'a K;

    fn next(&mut self) -> Option<Self::Item> {
        self.0.next()
    }

    fn size_hint(&self) -> (usize, Option<usize>) {
        self.0.size_hint()
    }
}

impl<'a, K> DoubleEndedIterator for Keys<'a, K>
where
    K: 'a,
{
    fn next_back(&mut self) -> Option<Self::Item> {
        self.0.next_back()
    }
}

impl<'a, K> ExactSizeIterator for Keys<'a, K> {}
impl<'a, K> FusedIterator for Keys<'a, K> {}