macro_rules! into_kv_types {
{$ktype:ty, $vtype:ty where {$($wheres:tt)+}} => {
pub struct IntoKeys<K, V>(IntoIter<K,V>);
impl<K,V> Iterator for IntoKeys<K,V> where $($wheres)+ {
type Item = $ktype;
fn next(&mut self) -> Option<Self::Item> {
self.0.next().map(|(k, _)| k)
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}
pub struct IntoValues<K, V>(IntoIter<K,V>);
impl<K,V> Iterator for IntoValues<K,V> where $($wheres)+ {
type Item = $vtype;
fn next(&mut self) -> Option<Self::Item> {
self.0.next().map(|(_, v)| v)
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}
}
}
pub(crate) use into_kv_types;
macro_rules! into_kv_methods {
{} => {
pub fn into_keys(self) -> IntoKeys<K,V> {
IntoKeys(self.into_iter())
}
pub fn into_values(self) -> IntoValues<K,V> {
IntoValues(self.into_iter())
}
}
}
pub(crate) use into_kv_methods;
macro_rules! ptr_into_kv_methods {
{} => {
pub fn into_keys(self) -> IntoKeys<ByPtr<K>, V> {
self.0.into_keys()
}
pub fn into_values(self) -> IntoValues<ByPtr<K>, V> {
self.0.into_values()
}
}
}
pub(crate) use ptr_into_kv_methods;
macro_rules! debug_for_entry {
{where {$($wheres:tt)+}} => {
impl<'a, K, V> Debug for OccupiedEntry<'a, K, V>
where
$($wheres)+
{
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
self.0.fmt(f)
}
}
impl<'a, K, V> Debug for VacantEntry<'a, K, V>
where
$($wheres)+
{
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
self.0.fmt(f)
}
}
impl<'a, K, V> Debug for Entry<'a, K, V>
where
$($wheres)+
{
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
Entry::Occupied(occupied_entry) => occupied_entry.fmt(f),
Entry::Vacant(vacant_entry) => vacant_entry.fmt(f),
}
}
}
}
}
pub(crate) use debug_for_entry;