use crate::abc::Keyed;
pub trait Values<'a>: Keyed
where
Self: 'a,
{
type Values: Iterator<Item = &'a Self::Value>;
fn values(&'a self) -> Self::Values;
}
pub trait IntoValues: Keyed {
type IntoValues: Iterator<Item = Self::Value>;
fn into_values(self) -> Self::IntoValues;
}
pub trait Iter<'a, K>: Keyed
where
Self: 'a,
{
type Iter: Iterator<Item = (K, &'a Self::Value)>;
fn iter(&'a self) -> Self::Iter;
}
pub trait IntoIter<K>: Keyed {
type IntoIter: Iterator<Item = (K, Self::Value)>;
fn into_iter(self) -> Self::IntoIter;
}
pub struct ValuesFromKeyValuePairs<I>(pub I);
impl<I, K, V> Iterator for ValuesFromKeyValuePairs<I>
where
I: Iterator<Item = (K, V)>,
{
type Item = V;
#[inline(always)]
fn next(&mut self) -> Option<V> {
self.0.next().map(|(_, value)| value)
}
#[inline(always)]
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}