1
Fork 0

SsoHashSet reimplemented as a wrapper on top of SsoHashMap

SsoHashSet::replace had to be removed because
it requires missing API from SsoHashMap.
It's not a widely used function, so I think it's ok
to omit it for now.

EitherIter moved into its own file.

Also sprinkled code with #[inline] attributes where appropriate.
This commit is contained in:
Valerii Lashmanov 2020-09-26 14:28:26 -05:00
parent 0600b178aa
commit 41942fac7d
4 changed files with 158 additions and 228 deletions

View file

@ -0,0 +1,75 @@
use std::fmt;
use std::iter::ExactSizeIterator;
use std::iter::FusedIterator;
use std::iter::Iterator;
/// Iterator which may contain instance of
/// one of two specific implementations.
///
/// Note: For most methods providing custom
/// implementation may margianlly
/// improve performance by avoiding
/// doing Left/Right match on every step
/// and doing it only once instead.
#[derive(Clone)]
pub enum EitherIter<L, R> {
Left(L),
Right(R),
}
impl<L, R> Iterator for EitherIter<L, R>
where
L: Iterator,
R: Iterator<Item = L::Item>,
{
type Item = L::Item;
fn next(&mut self) -> Option<Self::Item> {
match self {
EitherIter::Left(l) => l.next(),
EitherIter::Right(r) => r.next(),
}
}
fn size_hint(&self) -> (usize, Option<usize>) {
match self {
EitherIter::Left(l) => l.size_hint(),
EitherIter::Right(r) => r.size_hint(),
}
}
}
impl<L, R> ExactSizeIterator for EitherIter<L, R>
where
L: ExactSizeIterator,
R: ExactSizeIterator,
EitherIter<L, R>: Iterator,
{
fn len(&self) -> usize {
match self {
EitherIter::Left(l) => l.len(),
EitherIter::Right(r) => r.len(),
}
}
}
impl<L, R> FusedIterator for EitherIter<L, R>
where
L: FusedIterator,
R: FusedIterator,
EitherIter<L, R>: Iterator,
{
}
impl<L, R> fmt::Debug for EitherIter<L, R>
where
L: fmt::Debug,
R: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
EitherIter::Left(l) => l.fmt(f),
EitherIter::Right(r) => r.fmt(f),
}
}
}

View file

@ -1,4 +1,4 @@
use super::EitherIter; use super::either_iter::EitherIter;
use crate::fx::FxHashMap; use crate::fx::FxHashMap;
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use std::borrow::Borrow; use std::borrow::Borrow;
@ -32,6 +32,7 @@ pub enum SsoHashMap<K, V> {
impl<K, V> SsoHashMap<K, V> { impl<K, V> SsoHashMap<K, V> {
/// Creates an empty `SsoHashMap`. /// Creates an empty `SsoHashMap`.
#[inline]
pub fn new() -> Self { pub fn new() -> Self {
SsoHashMap::Array(ArrayVec::new()) SsoHashMap::Array(ArrayVec::new())
} }
@ -81,13 +82,15 @@ impl<K, V> SsoHashMap<K, V> {
/// An iterator visiting all key-value pairs in arbitrary order. /// An iterator visiting all key-value pairs in arbitrary order.
/// The iterator element type is `(&'a K, &'a V)`. /// The iterator element type is `(&'a K, &'a V)`.
pub fn iter(&self) -> impl Iterator<Item = (&'_ K, &'_ V)> { #[inline]
pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter {
self.into_iter() self.into_iter()
} }
/// An iterator visiting all key-value pairs in arbitrary order, /// An iterator visiting all key-value pairs in arbitrary order,
/// with mutable references to the values. /// with mutable references to the values.
/// The iterator element type is `(&'a K, &'a mut V)`. /// The iterator element type is `(&'a K, &'a mut V)`.
#[inline]
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&'_ K, &'_ mut V)> { pub fn iter_mut(&mut self) -> impl Iterator<Item = (&'_ K, &'_ mut V)> {
self.into_iter() self.into_iter()
} }
@ -319,12 +322,14 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> {
} }
/// Gets the given key's corresponding entry in the map for in-place manipulation. /// Gets the given key's corresponding entry in the map for in-place manipulation.
#[inline]
pub fn entry(&mut self, key: K) -> Entry<'_, K, V> { pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
Entry { ssomap: self, key } Entry { ssomap: self, key }
} }
} }
impl<K, V> Default for SsoHashMap<K, V> { impl<K, V> Default for SsoHashMap<K, V> {
#[inline]
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
} }
@ -348,6 +353,7 @@ impl<K: Eq + Hash, V> Extend<(K, V)> for SsoHashMap<K, V> {
} }
} }
#[inline]
fn extend_one(&mut self, (k, v): (K, V)) { fn extend_one(&mut self, (k, v): (K, V)) {
self.insert(k, v); self.insert(k, v);
} }
@ -375,10 +381,12 @@ where
self.extend(iter.into_iter().map(|(k, v)| (k.clone(), v.clone()))) self.extend(iter.into_iter().map(|(k, v)| (k.clone(), v.clone())))
} }
#[inline]
fn extend_one(&mut self, (&k, &v): (&'a K, &'a V)) { fn extend_one(&mut self, (&k, &v): (&'a K, &'a V)) {
self.insert(k, v); self.insert(k, v);
} }
#[inline]
fn extend_reserve(&mut self, additional: usize) { fn extend_reserve(&mut self, additional: usize) {
Extend::<(K, V)>::extend_reserve(self, additional) Extend::<(K, V)>::extend_reserve(self, additional)
} }
@ -400,12 +408,14 @@ impl<K, V> IntoIterator for SsoHashMap<K, V> {
} }
/// adapts Item of array reference iterator to Item of hashmap reference iterator. /// adapts Item of array reference iterator to Item of hashmap reference iterator.
#[inline(always)]
fn adapt_array_ref_it<K, V>(pair: &'a (K, V)) -> (&'a K, &'a V) { fn adapt_array_ref_it<K, V>(pair: &'a (K, V)) -> (&'a K, &'a V) {
let (a, b) = pair; let (a, b) = pair;
(a, b) (a, b)
} }
/// adapts Item of array mut reference iterator to Item of hashmap mut reference iterator. /// adapts Item of array mut reference iterator to Item of hashmap mut reference iterator.
#[inline(always)]
fn adapt_array_mut_it<K, V>(pair: &'a mut (K, V)) -> (&'a K, &'a mut V) { fn adapt_array_mut_it<K, V>(pair: &'a mut (K, V)) -> (&'a K, &'a mut V) {
let (a, b) = pair; let (a, b) = pair;
(a, b) (a, b)
@ -464,6 +474,7 @@ where
{ {
type Output = V; type Output = V;
#[inline]
fn index(&self, key: &Q) -> &V { fn index(&self, key: &Q) -> &V {
self.get(key).expect("no entry found for key") self.get(key).expect("no entry found for key")
} }
@ -490,6 +501,7 @@ impl<'a, K: Eq + Hash, V> Entry<'a, K, V> {
/// Ensures a value is in the entry by inserting the default if empty, and returns /// Ensures a value is in the entry by inserting the default if empty, and returns
/// a mutable reference to the value in the entry. /// a mutable reference to the value in the entry.
#[inline]
pub fn or_insert(self, value: V) -> &'a mut V { pub fn or_insert(self, value: V) -> &'a mut V {
self.or_insert_with(|| value) self.or_insert_with(|| value)
} }
@ -515,6 +527,7 @@ impl<'a, K: Eq + Hash, V> Entry<'a, K, V> {
} }
/// Returns a reference to this entry's key. /// Returns a reference to this entry's key.
#[inline]
pub fn key(&self) -> &K { pub fn key(&self) -> &K {
&self.key &self.key
} }
@ -523,6 +536,7 @@ impl<'a, K: Eq + Hash, V> Entry<'a, K, V> {
impl<'a, K: Eq + Hash, V: Default> Entry<'a, K, V> { impl<'a, K: Eq + Hash, V: Default> Entry<'a, K, V> {
/// Ensures a value is in the entry by inserting the default value if empty, /// Ensures a value is in the entry by inserting the default value if empty,
/// and returns a mutable reference to the value in the entry. /// and returns a mutable reference to the value in the entry.
#[inline]
pub fn or_default(self) -> &'a mut V { pub fn or_default(self) -> &'a mut V {
self.or_insert_with(Default::default) self.or_insert_with(Default::default)
} }

View file

@ -1,75 +1,4 @@
use std::fmt; mod either_iter;
use std::iter::ExactSizeIterator;
use std::iter::FusedIterator;
use std::iter::Iterator;
/// Iterator which may contain instance of
/// one of two specific implementations.
///
/// Used by both SsoHashMap and SsoHashSet.
#[derive(Clone)]
pub enum EitherIter<L, R> {
Left(L),
Right(R),
}
impl<L, R> Iterator for EitherIter<L, R>
where
L: Iterator,
R: Iterator<Item = L::Item>,
{
type Item = L::Item;
fn next(&mut self) -> Option<Self::Item> {
match self {
EitherIter::Left(l) => l.next(),
EitherIter::Right(r) => r.next(),
}
}
fn size_hint(&self) -> (usize, Option<usize>) {
match self {
EitherIter::Left(l) => l.size_hint(),
EitherIter::Right(r) => r.size_hint(),
}
}
}
impl<L, R> ExactSizeIterator for EitherIter<L, R>
where
L: ExactSizeIterator,
R: ExactSizeIterator,
EitherIter<L, R>: Iterator,
{
fn len(&self) -> usize {
match self {
EitherIter::Left(l) => l.len(),
EitherIter::Right(r) => r.len(),
}
}
}
impl<L, R> FusedIterator for EitherIter<L, R>
where
L: FusedIterator,
R: FusedIterator,
EitherIter<L, R>: Iterator,
{
}
impl<L, R> fmt::Debug for EitherIter<L, R>
where
L: fmt::Debug,
R: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
EitherIter::Left(l) => l.fmt(f),
EitherIter::Right(r) => r.fmt(f),
}
}
}
mod map; mod map;
mod set; mod set;

View file

@ -1,11 +1,10 @@
use super::EitherIter;
use crate::fx::FxHashSet;
use arrayvec::ArrayVec;
use std::borrow::Borrow; use std::borrow::Borrow;
use std::fmt; use std::fmt;
use std::hash::Hash; use std::hash::Hash;
use std::iter::FromIterator; use std::iter::FromIterator;
use super::map::SsoHashMap;
/// Small-storage-optimized implementation of a set. /// Small-storage-optimized implementation of a set.
/// ///
/// Stores elements in a small array up to a certain length /// Stores elements in a small array up to a certain length
@ -18,77 +17,73 @@ use std::iter::FromIterator;
/// try_reserve (unstable) /// try_reserve (unstable)
/// shrink_to (unstable) /// shrink_to (unstable)
/// drain_filter (unstable) /// drain_filter (unstable)
/// replace
/// get_or_insert/get_or_insert_owned/get_or_insert_with (unstable) /// get_or_insert/get_or_insert_owned/get_or_insert_with (unstable)
/// difference/symmetric_difference/intersection/union /// difference/symmetric_difference/intersection/union
/// is_disjoint/is_subset/is_superset /// is_disjoint/is_subset/is_superset
/// PartialEq/Eq (requires sorting the array) /// PartialEq/Eq (requires SsoHashMap implementation)
/// BitOr/BitAnd/BitXor/Sub /// BitOr/BitAnd/BitXor/Sub
#[derive(Clone)] #[derive(Clone)]
pub enum SsoHashSet<T> { pub struct SsoHashSet<T> {
Array(ArrayVec<[T; 8]>), map: SsoHashMap<T, ()>,
Set(FxHashSet<T>), }
/// Adapter function used ot return
/// result if SsoHashMap functions into
/// result SsoHashSet should return.
#[inline(always)]
fn entry_to_key<K, V>((k, _v): (K, V)) -> K {
k
} }
impl<T> SsoHashSet<T> { impl<T> SsoHashSet<T> {
/// Creates an empty `SsoHashSet`. /// Creates an empty `SsoHashSet`.
#[inline]
pub fn new() -> Self { pub fn new() -> Self {
SsoHashSet::Array(ArrayVec::new()) Self { map: SsoHashMap::new() }
} }
/// Creates an empty `SsoHashSet` with the specified capacity. /// Creates an empty `SsoHashSet` with the specified capacity.
#[inline]
pub fn with_capacity(cap: usize) -> Self { pub fn with_capacity(cap: usize) -> Self {
let array = ArrayVec::new(); Self { map: SsoHashMap::with_capacity(cap) }
if array.capacity() >= cap {
SsoHashSet::Array(array)
} else {
SsoHashSet::Set(FxHashSet::with_capacity_and_hasher(cap, Default::default()))
}
} }
/// Clears the set, removing all values. /// Clears the set, removing all values.
#[inline]
pub fn clear(&mut self) { pub fn clear(&mut self) {
match self { self.map.clear()
SsoHashSet::Array(array) => array.clear(),
SsoHashSet::Set(set) => set.clear(),
}
} }
/// Returns the number of elements the set can hold without reallocating. /// Returns the number of elements the set can hold without reallocating.
#[inline]
pub fn capacity(&self) -> usize { pub fn capacity(&self) -> usize {
match self { self.map.capacity()
SsoHashSet::Array(array) => array.capacity(),
SsoHashSet::Set(set) => set.capacity(),
}
} }
/// Returns the number of elements in the set. /// Returns the number of elements in the set.
#[inline]
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
match self { self.map.len()
SsoHashSet::Array(array) => array.len(),
SsoHashSet::Set(set) => set.len(),
}
} }
/// Returns `true` if the set contains no elements. /// Returns `true` if the set contains no elements.
#[inline]
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
match self { self.map.is_empty()
SsoHashSet::Array(array) => array.is_empty(),
SsoHashSet::Set(set) => set.is_empty(),
}
} }
/// An iterator visiting all elements in arbitrary order. /// An iterator visiting all elements in arbitrary order.
/// The iterator element type is `&'a T`. /// The iterator element type is `&'a T`.
#[inline]
pub fn iter(&'a self) -> impl Iterator<Item = &'a T> { pub fn iter(&'a self) -> impl Iterator<Item = &'a T> {
self.into_iter() self.into_iter()
} }
/// Clears the set, returning all elements in an iterator. /// Clears the set, returning all elements in an iterator.
#[inline]
pub fn drain(&mut self) -> impl Iterator<Item = T> + '_ { pub fn drain(&mut self) -> impl Iterator<Item = T> + '_ {
match self { self.map.drain().map(entry_to_key)
SsoHashSet::Array(array) => EitherIter::Left(array.drain(..)),
SsoHashSet::Set(set) => EitherIter::Right(set.drain()),
}
} }
} }
@ -96,95 +91,46 @@ impl<T: Eq + Hash> SsoHashSet<T> {
/// Reserves capacity for at least `additional` more elements to be inserted /// Reserves capacity for at least `additional` more elements to be inserted
/// in the `SsoHashSet`. The collection may reserve more space to avoid /// in the `SsoHashSet`. The collection may reserve more space to avoid
/// frequent reallocations. /// frequent reallocations.
#[inline]
pub fn reserve(&mut self, additional: usize) { pub fn reserve(&mut self, additional: usize) {
match self { self.map.reserve(additional)
SsoHashSet::Array(array) => {
if array.capacity() < (array.len() + additional) {
let mut set: FxHashSet<T> = array.drain(..).collect();
set.reserve(additional);
*self = SsoHashSet::Set(set);
}
}
SsoHashSet::Set(set) => set.reserve(additional),
}
} }
/// Shrinks the capacity of the set as much as possible. It will drop /// Shrinks the capacity of the set as much as possible. It will drop
/// down as much as possible while maintaining the internal rules /// down as much as possible while maintaining the internal rules
/// and possibly leaving some space in accordance with the resize policy. /// and possibly leaving some space in accordance with the resize policy.
#[inline]
pub fn shrink_to_fit(&mut self) { pub fn shrink_to_fit(&mut self) {
if let SsoHashSet::Set(set) = self { self.map.shrink_to_fit()
let mut array = ArrayVec::new();
if set.len() <= array.capacity() {
array.extend(set.drain());
*self = SsoHashSet::Array(array);
} else {
set.shrink_to_fit();
}
}
} }
/// Retains only the elements specified by the predicate. /// Retains only the elements specified by the predicate.
#[inline]
pub fn retain<F>(&mut self, mut f: F) pub fn retain<F>(&mut self, mut f: F)
where where
F: FnMut(&T) -> bool, F: FnMut(&T) -> bool,
{ {
match self { self.map.retain(|k, _v| f(k))
SsoHashSet::Array(array) => array.retain(|v| f(v)),
SsoHashSet::Set(set) => set.retain(f),
}
} }
/// Removes and returns the value in the set, if any, that is equal to the given one. /// Removes and returns the value in the set, if any, that is equal to the given one.
#[inline]
pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T> pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
where where
T: Borrow<Q>, T: Borrow<Q>,
Q: Hash + Eq, Q: Hash + Eq,
{ {
match self { self.map.remove_entry(value).map(entry_to_key)
SsoHashSet::Array(array) => {
if let Some(index) = array.iter().position(|val| val.borrow() == value) {
Some(array.swap_remove(index))
} else {
None
}
}
SsoHashSet::Set(set) => set.take(value),
}
}
/// Adds a value to the set, replacing the existing value, if any, that is equal to the given
/// one. Returns the replaced value.
pub fn replace(&mut self, value: T) -> Option<T> {
match self {
SsoHashSet::Array(array) => {
if let Some(index) = array.iter().position(|val| *val == value) {
let old_value = std::mem::replace(&mut array[index], value);
Some(old_value)
} else {
None
}
}
SsoHashSet::Set(set) => set.replace(value),
}
} }
/// Returns a reference to the value in the set, if any, that is equal to the given value. /// Returns a reference to the value in the set, if any, that is equal to the given value.
#[inline]
pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T> pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
where where
T: Borrow<Q>, T: Borrow<Q>,
Q: Hash + Eq, Q: Hash + Eq,
{ {
match self { self.map.get_key_value(value).map(entry_to_key)
SsoHashSet::Array(array) => {
if let Some(index) = array.iter().position(|val| val.borrow() == value) {
Some(&array[index])
} else {
None
}
}
SsoHashSet::Set(set) => set.get(value),
}
} }
/// Adds a value to the set. /// Adds a value to the set.
@ -192,60 +138,30 @@ impl<T: Eq + Hash> SsoHashSet<T> {
/// If the set did not have this value present, `true` is returned. /// If the set did not have this value present, `true` is returned.
/// ///
/// If the set did have this value present, `false` is returned. /// If the set did have this value present, `false` is returned.
#[inline]
pub fn insert(&mut self, elem: T) -> bool { pub fn insert(&mut self, elem: T) -> bool {
match self { self.map.insert(elem, ()).is_none()
SsoHashSet::Array(array) => {
if array.iter().any(|e| *e == elem) {
false
} else {
if let Err(error) = array.try_push(elem) {
let mut set: FxHashSet<T> = array.drain(..).collect();
set.insert(error.element());
*self = SsoHashSet::Set(set);
}
true
}
}
SsoHashSet::Set(set) => set.insert(elem),
}
} }
/// Removes a value from the set. Returns whether the value was /// Removes a value from the set. Returns whether the value was
/// present in the set. /// present in the set.
#[inline]
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
where where
T: Borrow<Q>, T: Borrow<Q>,
Q: Hash + Eq, Q: Hash + Eq,
{ {
match self { self.map.remove(value).is_some()
SsoHashSet::Array(array) => {
if let Some(index) = array.iter().position(|val| val.borrow() == value) {
array.swap_remove(index);
true
} else {
false
}
}
SsoHashSet::Set(set) => set.remove(value),
}
} }
/// Returns `true` if the set contains a value. /// Returns `true` if the set contains a value.
#[inline]
pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
where where
T: Borrow<Q>, T: Borrow<Q>,
Q: Hash + Eq, Q: Hash + Eq,
{ {
match self { self.map.contains_key(value)
SsoHashSet::Array(array) => array.iter().any(|v| v.borrow() == value),
SsoHashSet::Set(set) => set.contains(value),
}
}
}
impl<T> Default for SsoHashSet<T> {
fn default() -> Self {
Self::new()
} }
} }
@ -257,6 +173,13 @@ impl<T: Eq + Hash> FromIterator<T> for SsoHashSet<T> {
} }
} }
impl<T> Default for SsoHashSet<T> {
#[inline]
fn default() -> Self {
Self::new()
}
}
impl<T: Eq + Hash> Extend<T> for SsoHashSet<T> { impl<T: Eq + Hash> Extend<T> for SsoHashSet<T> {
fn extend<I>(&mut self, iter: I) fn extend<I>(&mut self, iter: I)
where where
@ -267,21 +190,14 @@ impl<T: Eq + Hash> Extend<T> for SsoHashSet<T> {
} }
} }
#[inline]
fn extend_one(&mut self, item: T) { fn extend_one(&mut self, item: T) {
self.insert(item); self.insert(item);
} }
#[inline]
fn extend_reserve(&mut self, additional: usize) { fn extend_reserve(&mut self, additional: usize) {
match self { self.map.extend_reserve(additional)
SsoHashSet::Array(array) => {
if array.capacity() < (array.len() + additional) {
let mut set: FxHashSet<T> = array.drain(..).collect();
set.extend_reserve(additional);
*self = SsoHashSet::Set(set);
}
}
SsoHashSet::Set(set) => set.extend_reserve(additional),
}
} }
} }
@ -289,46 +205,42 @@ impl<'a, T> Extend<&'a T> for SsoHashSet<T>
where where
T: 'a + Eq + Hash + Copy, T: 'a + Eq + Hash + Copy,
{ {
#[inline]
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) { fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
self.extend(iter.into_iter().cloned()); self.extend(iter.into_iter().cloned());
} }
#[inline]
fn extend_one(&mut self, &item: &'a T) { fn extend_one(&mut self, &item: &'a T) {
self.insert(item); self.insert(item);
} }
#[inline]
fn extend_reserve(&mut self, additional: usize) { fn extend_reserve(&mut self, additional: usize) {
Extend::<T>::extend_reserve(self, additional) Extend::<T>::extend_reserve(self, additional)
} }
} }
impl<T> IntoIterator for SsoHashSet<T> { impl<T> IntoIterator for SsoHashSet<T> {
type IntoIter = EitherIter< type IntoIter = std::iter::Map<<SsoHashMap<T, ()> as IntoIterator>::IntoIter, fn((T, ())) -> T>;
<ArrayVec<[T; 8]> as IntoIterator>::IntoIter,
<FxHashSet<T> as IntoIterator>::IntoIter,
>;
type Item = <Self::IntoIter as Iterator>::Item; type Item = <Self::IntoIter as Iterator>::Item;
#[inline]
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
match self { self.map.into_iter().map(entry_to_key)
SsoHashSet::Array(array) => EitherIter::Left(array.into_iter()),
SsoHashSet::Set(set) => EitherIter::Right(set.into_iter()),
}
} }
} }
impl<'a, T> IntoIterator for &'a SsoHashSet<T> { impl<'a, T> IntoIterator for &'a SsoHashSet<T> {
type IntoIter = EitherIter< type IntoIter = std::iter::Map<
<&'a ArrayVec<[T; 8]> as IntoIterator>::IntoIter, <&'a SsoHashMap<T, ()> as IntoIterator>::IntoIter,
<&'a FxHashSet<T> as IntoIterator>::IntoIter, fn((&'a T, &'a ())) -> &'a T,
>; >;
type Item = <Self::IntoIter as Iterator>::Item; type Item = <Self::IntoIter as Iterator>::Item;
#[inline]
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
match self { self.map.iter().map(entry_to_key)
SsoHashSet::Array(array) => EitherIter::Left(array.into_iter()),
SsoHashSet::Set(set) => EitherIter::Right(set.into_iter()),
}
} }
} }