Coverage Report

Created: 2026-11-23 07:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wasm-tools/crates/wasmparser/src/collections/index_map.rs
Line
Count
Source
1
//! Type definitions for an ordered map.
2
3
use core::borrow::Borrow;
4
use core::hash::Hash;
5
use core::iter::FusedIterator;
6
use core::ops::Index;
7
8
mod detail;
9
10
#[cfg(test)]
11
mod tests;
12
13
/// A hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.
14
///
15
/// Provides an API compatible with both [`IndexMap`] and a custom implementation based on [`BTreeMap`].
16
///
17
/// [`IndexMap`]: indexmap::IndexMap
18
/// [`BTreeMap`]: alloc::collections::BTreeMap
19
#[derive(Debug, Clone)]
20
pub struct IndexMap<K, V> {
21
    inner: detail::IndexMapImpl<K, V>,
22
}
23
24
impl<K, V> Default for IndexMap<K, V> {
25
    #[inline]
26
3.35M
    fn default() -> Self {
27
3.35M
        Self {
28
3.35M
            inner: detail::IndexMapImpl::default(),
29
3.35M
        }
30
3.35M
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem> as core::default::Default>::default
Line
Count
Source
26
613k
    fn default() -> Self {
27
613k
        Self {
28
613k
            inner: detail::IndexMapImpl::default(),
29
613k
        }
30
613k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::default::Default>::default
Line
Count
Source
26
26.2k
    fn default() -> Self {
27
26.2k
        Self {
28
26.2k
            inner: detail::IndexMapImpl::default(),
29
26.2k
        }
30
26.2k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType> as core::default::Default>::default
Line
Count
Source
26
69.8k
    fn default() -> Self {
27
69.8k
        Self {
28
69.8k
            inner: detail::IndexMapImpl::default(),
29
69.8k
        }
30
69.8k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, ()> as core::default::Default>::default
Line
Count
Source
26
508k
    fn default() -> Self {
27
508k
        Self {
28
508k
            inner: detail::IndexMapImpl::default(),
29
508k
        }
30
508k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>> as core::default::Default>::default
Line
Count
Source
26
402k
    fn default() -> Self {
27
402k
        Self {
28
402k
            inner: detail::IndexMapImpl::default(),
29
402k
        }
30
402k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>> as core::default::Default>::default
Line
Count
Source
26
507k
    fn default() -> Self {
27
507k
        Self {
28
507k
            inner: detail::IndexMapImpl::default(),
29
507k
        }
30
507k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()> as core::default::Default>::default
Line
Count
Source
26
148k
    fn default() -> Self {
27
148k
        Self {
28
148k
            inner: detail::IndexMapImpl::default(),
29
148k
        }
30
148k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase> as core::default::Default>::default
Line
Count
Source
26
12.0k
    fn default() -> Self {
27
12.0k
        Self {
28
12.0k
            inner: detail::IndexMapImpl::default(),
29
12.0k
        }
30
12.0k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType> as core::default::Default>::default
Line
Count
Source
26
35.1k
    fn default() -> Self {
27
35.1k
        Self {
28
35.1k
            inner: detail::IndexMapImpl::default(),
29
35.1k
        }
30
35.1k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()> as core::default::Default>::default
Line
Count
Source
26
394k
    fn default() -> Self {
27
394k
        Self {
28
394k
            inner: detail::IndexMapImpl::default(),
29
394k
        }
30
394k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::ComponentName, ()> as core::default::Default>::default
Line
Count
Source
26
508k
    fn default() -> Self {
27
508k
        Self {
28
508k
            inner: detail::IndexMapImpl::default(),
29
508k
        }
30
508k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::types::CoreTypeId, u8> as core::default::Default>::default
Line
Count
Source
26
47.5k
    fn default() -> Self {
27
47.5k
        Self {
28
47.5k
            inner: detail::IndexMapImpl::default(),
29
47.5k
        }
30
47.5k
    }
<wasmparser::collections::index_map::IndexMap<&str, &wasmparser::validator::component_types::InstanceType> as core::default::Default>::default
Line
Count
Source
26
33.1k
    fn default() -> Self {
27
33.1k
        Self {
28
33.1k
            inner: detail::IndexMapImpl::default(),
29
33.1k
        }
30
33.1k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>> as core::default::Default>::default
Line
Count
Source
26
50.6k
    fn default() -> Self {
27
50.6k
        Self {
28
50.6k
            inner: detail::IndexMapImpl::default(),
29
50.6k
        }
30
50.6k
    }
31
}
32
33
impl<K, V> IndexMap<K, V> {
34
    /// Clears the [`IndexMap`], removing all elements.
35
    #[inline]
36
148k
    pub fn clear(&mut self) {
37
148k
        self.inner.clear()
38
148k
    }
39
40
    /// Returns the number of elements in the [`IndexMap`].
41
    #[inline]
42
895k
    pub fn len(&self) -> usize {
43
895k
        self.inner.len()
44
895k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::len
Line
Count
Source
42
787k
    pub fn len(&self) -> usize {
43
787k
        self.inner.len()
44
787k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType>>::len
Line
Count
Source
42
28.2k
    pub fn len(&self) -> usize {
43
28.2k
        self.inner.len()
44
28.2k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, ()>>::len
Line
Count
Source
42
22.5k
    pub fn len(&self) -> usize {
43
22.5k
        self.inner.len()
44
22.5k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::len
Line
Count
Source
42
3.98k
    pub fn len(&self) -> usize {
43
3.98k
        self.inner.len()
44
3.98k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::len
Line
Count
Source
42
14.8k
    pub fn len(&self) -> usize {
43
14.8k
        self.inner.len()
44
14.8k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()>>::len
Line
Count
Source
42
8.98k
    pub fn len(&self) -> usize {
43
8.98k
        self.inner.len()
44
8.98k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<wasmparser::validator::types::CoreTypeId, u8>>::len
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>>::len
Line
Count
Source
42
29.9k
    pub fn len(&self) -> usize {
43
29.9k
        self.inner.len()
44
29.9k
    }
45
46
    /// Returns `true` if the [`IndexMap`] contains no elements.
47
    #[inline]
48
105k
    pub fn is_empty(&self) -> bool {
49
105k
        self.inner.is_empty()
50
105k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>>>::is_empty
Line
Count
Source
48
105k
    pub fn is_empty(&self) -> bool {
49
105k
        self.inner.is_empty()
50
105k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()>>::is_empty
51
52
    /// Returns an iterator that yields the items in the [`IndexMap`].
53
    #[inline]
54
671k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
671k
        Iter {
56
671k
            inner: self.inner.iter(),
57
671k
        }
58
671k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::iter
Line
Count
Source
54
325k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
325k
        Iter {
56
325k
            inner: self.inner.iter(),
57
325k
        }
58
325k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType>>::iter
Line
Count
Source
54
33.1k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
33.1k
        Iter {
56
33.1k
            inner: self.inner.iter(),
57
33.1k
        }
58
33.1k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>>>::iter
Line
Count
Source
54
148k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
148k
        Iter {
56
148k
            inner: self.inner.iter(),
57
148k
        }
58
148k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()>>::iter
Line
Count
Source
54
26.2k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
26.2k
        Iter {
56
26.2k
            inner: self.inner.iter(),
57
26.2k
        }
58
26.2k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::AliasableResourceId, ()>>::iter
Line
Count
Source
54
2.46k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
2.46k
        Iter {
56
2.46k
            inner: self.inner.iter(),
57
2.46k
        }
58
2.46k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::iter
Line
Count
Source
54
6.71k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
6.71k
        Iter {
56
6.71k
            inner: self.inner.iter(),
57
6.71k
        }
58
6.71k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::iter
Line
Count
Source
54
20.0k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
20.0k
        Iter {
56
20.0k
            inner: self.inner.iter(),
57
20.0k
        }
58
20.0k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()>>::iter
Line
Count
Source
54
42.1k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
42.1k
        Iter {
56
42.1k
            inner: self.inner.iter(),
57
42.1k
        }
58
42.1k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>>::iter
Line
Count
Source
54
33.1k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
33.1k
        Iter {
56
33.1k
            inner: self.inner.iter(),
57
33.1k
        }
58
33.1k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), wasmparser::validator::types::EntityType>>::iter
Line
Count
Source
54
33.1k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
33.1k
        Iter {
56
33.1k
            inner: self.inner.iter(),
57
33.1k
        }
58
33.1k
    }
59
60
    /// Returns an iterator that yields the mutable items in the [`IndexMap`].
61
    #[inline]
62
0
    pub fn iter_mut(&mut self) -> IterMut<'_, K, V> {
63
0
        IterMut {
64
0
            inner: self.inner.iter_mut(),
65
0
        }
66
0
    }
67
68
    /// Returns an iterator that yields the keys in the [`IndexMap`].
69
    #[inline]
70
42.1k
    pub fn keys(&self) -> Keys<'_, K, V> {
71
42.1k
        Keys {
72
42.1k
            inner: self.inner.keys(),
73
42.1k
        }
74
42.1k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::keys
Line
Count
Source
70
42.1k
    pub fn keys(&self) -> Keys<'_, K, V> {
71
42.1k
        Keys {
72
42.1k
            inner: self.inner.keys(),
73
42.1k
        }
74
42.1k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<_, _>>::keys
75
76
    /// Returns an iterator that yields the values in the [`IndexMap`].
77
    #[inline]
78
1.23M
    pub fn values(&self) -> Values<'_, K, V> {
79
1.23M
        Values {
80
1.23M
            inner: self.inner.values(),
81
1.23M
        }
82
1.23M
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::values
Line
Count
Source
78
962k
    pub fn values(&self) -> Values<'_, K, V> {
79
962k
        Values {
80
962k
            inner: self.inner.values(),
81
962k
        }
82
962k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::values
Line
Count
Source
78
69.8k
    pub fn values(&self) -> Values<'_, K, V> {
79
69.8k
        Values {
80
69.8k
            inner: self.inner.values(),
81
69.8k
        }
82
69.8k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::values
Line
Count
Source
78
205k
    pub fn values(&self) -> Values<'_, K, V> {
79
205k
        Values {
80
205k
            inner: self.inner.values(),
81
205k
        }
82
205k
    }
83
84
    /// Returns a mutable iterator that yields the values in the [`IndexMap`].
85
    #[inline]
86
61.3k
    pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
87
61.3k
        ValuesMut {
88
61.3k
            inner: self.inner.values_mut(),
89
61.3k
        }
90
61.3k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::values_mut
Line
Count
Source
86
34.7k
    pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
87
34.7k
        ValuesMut {
88
34.7k
            inner: self.inner.values_mut(),
89
34.7k
        }
90
34.7k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::values_mut
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::values_mut
Line
Count
Source
86
6.28k
    pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
87
6.28k
        ValuesMut {
88
6.28k
            inner: self.inner.values_mut(),
89
6.28k
        }
90
6.28k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::values_mut
Line
Count
Source
86
20.2k
    pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
87
20.2k
        ValuesMut {
88
20.2k
            inner: self.inner.values_mut(),
89
20.2k
        }
90
20.2k
    }
91
92
    /// Returns the key-value entry at the given `index` if any.
93
    #[inline]
94
29.2k
    pub fn get_index(&self, index: usize) -> Option<(&K, &V)> {
95
29.2k
        self.inner.get_index(index)
96
29.2k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::get_index
Line
Count
Source
94
3.87k
    pub fn get_index(&self, index: usize) -> Option<(&K, &V)> {
95
3.87k
        self.inner.get_index(index)
96
3.87k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, ()>>::get_index
Line
Count
Source
94
25.3k
    pub fn get_index(&self, index: usize) -> Option<(&K, &V)> {
95
25.3k
        self.inner.get_index(index)
96
25.3k
    }
97
98
    /// Returns the mutable key-value entry at the given `index` if any.
99
    #[inline]
100
0
    pub fn get_index_mut(&mut self, index: usize) -> Option<(&K, &mut V)> {
101
0
        self.inner.get_index_mut(index)
102
0
    }
103
}
104
105
impl<K, V> IndexMap<K, V>
106
where
107
    K: Hash + Eq + Ord + Clone,
108
{
109
    /// Reserves capacity for at least `additional` more elements to be inserted in the [`IndexMap`].
110
    #[inline]
111
752k
    pub fn reserve(&mut self, additional: usize) {
112
752k
        self.inner.reserve(additional);
113
752k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::reserve
Line
Count
Source
111
253k
    pub fn reserve(&mut self, additional: usize) {
112
253k
        self.inner.reserve(additional);
113
253k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType>>::reserve
Line
Count
Source
111
28.2k
    pub fn reserve(&mut self, additional: usize) {
112
28.2k
        self.inner.reserve(additional);
113
28.2k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::reserve
Line
Count
Source
111
12.0k
    pub fn reserve(&mut self, additional: usize) {
112
12.0k
        self.inner.reserve(additional);
113
12.0k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::reserve
Line
Count
Source
111
35.1k
    pub fn reserve(&mut self, additional: usize) {
112
35.1k
        self.inner.reserve(additional);
113
35.1k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()>>::reserve
Line
Count
Source
111
394k
    pub fn reserve(&mut self, additional: usize) {
112
394k
        self.inner.reserve(additional);
113
394k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>>::reserve
Line
Count
Source
111
29.9k
    pub fn reserve(&mut self, additional: usize) {
112
29.9k
        self.inner.reserve(additional);
113
29.9k
    }
114
115
    /// Returns true if `key` is contains in the [`IndexMap`].
116
    #[inline]
117
47.2k
    pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
118
47.2k
    where
119
47.2k
        K: Borrow<Q>,
120
47.2k
        Q: Hash + Eq + Ord,
121
    {
122
47.2k
        self.inner.contains_key(key)
123
47.2k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, ()>>::contains_key::<str>
Line
Count
Source
117
26.5k
    pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
118
26.5k
    where
119
26.5k
        K: Borrow<Q>,
120
26.5k
        Q: Hash + Eq + Ord,
121
    {
122
26.5k
        self.inner.contains_key(key)
123
26.5k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()>>::contains_key::<wasmparser::validator::component_types::ResourceId>
Line
Count
Source
117
20.6k
    pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
118
20.6k
    where
119
20.6k
        K: Borrow<Q>,
120
20.6k
        Q: Hash + Eq + Ord,
121
    {
122
20.6k
        self.inner.contains_key(key)
123
20.6k
    }
124
125
    /// Returns a reference to the value corresponding to the `key`.
126
    #[inline]
127
673k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
673k
    where
129
673k
        K: Borrow<Q>,
130
673k
        Q: Hash + Eq + Ord,
131
    {
132
673k
        self.inner.get(key)
133
673k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::get::<alloc::string::String>
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::get::<str>
Line
Count
Source
127
94.3k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
94.3k
    where
129
94.3k
        K: Borrow<Q>,
130
94.3k
        Q: Hash + Eq + Ord,
131
    {
132
94.3k
        self.inner.get(key)
133
94.3k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::get::<alloc::string::String>
Line
Count
Source
127
55.9k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
55.9k
    where
129
55.9k
        K: Borrow<Q>,
130
55.9k
        Q: Hash + Eq + Ord,
131
    {
132
55.9k
        self.inner.get(key)
133
55.9k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType>>::get::<alloc::string::String>
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType>>::get::<str>
Line
Count
Source
127
322k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
322k
    where
129
322k
        K: Borrow<Q>,
130
322k
        Q: Hash + Eq + Ord,
131
    {
132
322k
        self.inner.get(key)
133
322k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>>>::get::<wasmparser::validator::component_types::ResourceId>
Line
Count
Source
127
14.3k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
14.3k
    where
129
14.3k
        K: Borrow<Q>,
130
14.3k
        Q: Hash + Eq + Ord,
131
    {
132
14.3k
        self.inner.get(key)
133
14.3k
    }
<wasmparser::collections::index_map::IndexMap<&str, &wasmparser::validator::component_types::InstanceType>>::get::<str>
Line
Count
Source
127
186k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
186k
    where
129
186k
        K: Borrow<Q>,
130
186k
        Q: Hash + Eq + Ord,
131
    {
132
186k
        self.inner.get(key)
133
186k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), wasmparser::validator::types::EntityType>>::get::<(alloc::string::String, alloc::string::String)>
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), wasmparser::validator::types::EntityType>>::get::<dyn wasmparser::validator::component_types::ModuleImportKey>
134
135
    /// Return references to the key-value pair stored for `key`,
136
    /// if it is present, else `None`.
137
    #[inline]
138
0
    pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(&K, &V)>
139
0
    where
140
0
        K: Borrow<Q>,
141
0
        Q: Hash + Eq + Ord,
142
    {
143
0
        self.inner.get_key_value(key)
144
0
    }
145
146
    /// Returns the key-value pair corresponding to the supplied key
147
    /// as well as the unique index of the returned key-value pair.
148
    ///
149
    /// The supplied key may be any borrowed form of the map's key type,
150
    /// but the ordering on the borrowed form *must* match the ordering
151
    /// on the key type.
152
    #[inline]
153
0
    pub fn get_full<Q: ?Sized>(&self, key: &Q) -> Option<(usize, &K, &V)>
154
0
    where
155
0
        K: Borrow<Q> + Ord,
156
0
        Q: Hash + Eq + Ord,
157
    {
158
0
        self.inner.get_full(key)
159
0
    }
160
161
    /// Returns a mutable reference to the value corresponding to the key.
162
    #[inline]
163
0
    pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V>
164
0
    where
165
0
        K: Borrow<Q>,
166
0
        Q: Hash + Eq + Ord,
167
    {
168
0
        self.inner.get_mut(key)
169
0
    }
170
171
    /// Inserts a key-value pair into the [`IndexMap`].
172
    ///
173
    /// If the map did not have this key present, `None` is returned.
174
    ///
175
    /// If the map did have this key present, the value is updated, and the old
176
    /// value is returned. The key is not updated, though; this matters for
177
    /// types that can be `==` without being identical.
178
    #[inline]
179
5.36M
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
5.36M
        self.inner.insert(key, value)
181
5.36M
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType>>::insert
Line
Count
Source
179
440k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
440k
        self.inner.insert(key, value)
181
440k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, ()>>::insert
Line
Count
Source
179
22.5k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
22.5k
        self.inner.insert(key, value)
181
22.5k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>>>::insert
Line
Count
Source
179
7.90k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
7.90k
        self.inner.insert(key, value)
181
7.90k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>>>::insert
Line
Count
Source
179
19.7k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
19.7k
        self.inner.insert(key, value)
181
19.7k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()>>::insert
Line
Count
Source
179
130k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
130k
        self.inner.insert(key, value)
181
130k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()>>::insert
Line
Count
Source
179
3.53M
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
3.53M
        self.inner.insert(key, value)
181
3.53M
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::ComponentName, ()>>::insert
Line
Count
Source
179
842k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
842k
        self.inner.insert(key, value)
181
842k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::types::CoreTypeId, u8>>::insert
Line
Count
Source
179
332k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
332k
        self.inner.insert(key, value)
181
332k
    }
<wasmparser::collections::index_map::IndexMap<&str, &wasmparser::validator::component_types::InstanceType>>::insert
Line
Count
Source
179
38.0k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
38.0k
        self.inner.insert(key, value)
181
38.0k
    }
182
183
    /// Remove the key-value pair equivalent to `key` and return its value.
184
    ///
185
    /// Like [`Vec::swap_remove`], the pair is removed by swapping it with the
186
    /// last element of the map and popping it off. **This perturbs
187
    /// the position of what used to be the last element!**
188
    ///
189
    /// Return `None` if `key` is not in map.
190
    ///
191
    /// [`Vec::swap_remove`]: alloc::vec::Vec::swap_remove
192
    #[inline]
193
16.4k
    pub fn swap_remove<Q>(&mut self, key: &Q) -> Option<V>
194
16.4k
    where
195
16.4k
        K: Borrow<Q>,
196
16.4k
        Q: ?Sized + Hash + Eq + Ord,
197
    {
198
16.4k
        self.inner.swap_remove(key)
199
16.4k
    }
200
201
    /// Remove and return the key-value pair equivalent to `key`.
202
    ///
203
    /// Like [`Vec::swap_remove`], the pair is removed by swapping it with the
204
    /// last element of the map and popping it off. **This perturbs
205
    /// the position of what used to be the last element!**
206
    ///
207
    /// Return `None` if `key` is not in map.
208
    ///
209
    /// [`Vec::swap_remove`]: alloc::vec::Vec::swap_remove
210
    #[inline]
211
4.37M
    pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
212
4.37M
    where
213
4.37M
        K: Borrow<Q>,
214
4.37M
        Q: ?Sized + Hash + Eq + Ord,
215
    {
216
4.37M
        self.inner.swap_remove_entry(key)
217
4.37M
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()>>::swap_remove_entry::<wasmparser::validator::names::KebabString>
Line
Count
Source
211
3.53M
    pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
212
3.53M
    where
213
3.53M
        K: Borrow<Q>,
214
3.53M
        Q: ?Sized + Hash + Eq + Ord,
215
    {
216
3.53M
        self.inner.swap_remove_entry(key)
217
3.53M
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::ComponentName, ()>>::swap_remove_entry::<wasmparser::validator::names::ComponentName>
Line
Count
Source
211
842k
    pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
212
842k
    where
213
842k
        K: Borrow<Q>,
214
842k
        Q: ?Sized + Hash + Eq + Ord,
215
    {
216
842k
        self.inner.swap_remove_entry(key)
217
842k
    }
218
219
    /// Gets the given key's corresponding entry in the [`IndexMap`] for in-place manipulation.
220
    #[inline]
221
1.49M
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
1.49M
        match self.inner.entry(key) {
223
126k
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
1.37M
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
1.49M
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::entry
Line
Count
Source
221
842k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
842k
        match self.inner.entry(key) {
223
0
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
842k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
842k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::entry
Line
Count
Source
221
52.0k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
52.0k
        match self.inner.entry(key) {
223
0
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
52.0k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
52.0k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::entry
Line
Count
Source
221
60.1k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
60.1k
        match self.inner.entry(key) {
223
0
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
60.1k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
60.1k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::entry
Line
Count
Source
221
168k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
168k
        match self.inner.entry(key) {
223
0
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
168k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
168k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>>::entry
Line
Count
Source
221
376k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
376k
        match self.inner.entry(key) {
223
126k
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
250k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
376k
    }
227
}
228
229
impl<K, Q, V> Index<&Q> for IndexMap<K, V>
230
where
231
    K: Borrow<Q> + Hash + Eq + Ord,
232
    Q: ?Sized + Hash + Eq + Ord,
233
{
234
    type Output = V;
235
236
    #[inline]
237
95.0k
    fn index(&self, key: &Q) -> &V {
238
95.0k
        &self.inner[key]
239
95.0k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem> as core::ops::index::Index<&alloc::string::String>>::index
Line
Count
Source
237
37.4k
    fn index(&self, key: &Q) -> &V {
238
37.4k
        &self.inner[key]
239
37.4k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::types::CoreTypeId, u8> as core::ops::index::Index<&wasmparser::validator::types::CoreTypeId>>::index
Line
Count
Source
237
57.6k
    fn index(&self, key: &Q) -> &V {
238
57.6k
        &self.inner[key]
239
57.6k
    }
240
}
241
242
impl<K, V> Index<usize> for IndexMap<K, V>
243
where
244
    K: Hash + Eq + Ord,
245
{
246
    type Output = V;
247
248
    #[inline]
249
4.76k
    fn index(&self, key: usize) -> &V {
250
4.76k
        &self.inner[key]
251
4.76k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentItem> as core::ops::index::Index<usize>>::index
Line
Count
Source
249
4.76k
    fn index(&self, key: usize) -> &V {
250
4.76k
        &self.inner[key]
251
4.76k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<_, _> as core::ops::index::Index<usize>>::index
252
}
253
254
impl<K, V> Extend<(K, V)> for IndexMap<K, V>
255
where
256
    K: Eq + Hash + Ord + Clone,
257
{
258
    #[inline]
259
0
    fn extend<Iter: IntoIterator<Item = (K, V)>>(&mut self, iter: Iter) {
260
0
        self.inner.extend(iter)
261
0
    }
262
}
263
264
/// A view into a single entry in a [`IndexMap`], which may either be vacant or occupied.
265
///
266
/// This enum is constructed from the entry method on [`IndexMap`].
267
#[derive(Debug)]
268
pub enum Entry<'a, K: Ord, V> {
269
    /// An occupied entry.
270
    Occupied(OccupiedEntry<'a, K, V>),
271
    /// A vacant entry.
272
    Vacant(VacantEntry<'a, K, V>),
273
}
274
275
impl<'a, K, V> Entry<'a, K, V>
276
where
277
    K: Hash + Eq + Ord + Clone,
278
{
279
    /// Returns a reference to this entry's key.
280
    #[inline]
281
0
    pub fn key(&self) -> &K {
282
0
        match *self {
283
0
            Self::Occupied(ref entry) => entry.key(),
284
0
            Self::Vacant(ref entry) => entry.key(),
285
        }
286
0
    }
287
}
288
289
impl<'a, K, V> Entry<'a, K, V>
290
where
291
    K: Hash + Eq + Ord + Clone,
292
    V: Default,
293
{
294
    /// Ensures a value is in the entry by inserting the default value if empty,
295
    /// and returns a mutable reference to the value in the entry.
296
    #[inline]
297
376k
    pub fn or_default(self) -> &'a mut V {
298
376k
        match self {
299
126k
            Self::Occupied(entry) => entry.into_mut(),
300
250k
            Self::Vacant(entry) => entry.insert(Default::default()),
301
        }
302
376k
    }
303
}
304
305
/// A view into an occupied entry in a [`IndexMap`].
306
///
307
/// It is part of the [`Entry`] enum.
308
#[derive(Debug)]
309
pub struct OccupiedEntry<'a, K: Ord, V> {
310
    inner: detail::OccupiedEntryImpl<'a, K, V>,
311
}
312
313
impl<'a, K: 'a, V: 'a> OccupiedEntry<'a, K, V>
314
where
315
    K: Ord + Clone,
316
{
317
    /// Gets a reference to the key in the entry.
318
    #[inline]
319
0
    pub fn key(&self) -> &K {
320
0
        self.inner.key()
321
0
    }
Unexecuted instantiation: <wasmparser::collections::index_map::OccupiedEntry<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::key
Unexecuted instantiation: <wasmparser::collections::index_map::OccupiedEntry<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::key
Unexecuted instantiation: <wasmparser::collections::index_map::OccupiedEntry<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::key
Unexecuted instantiation: <wasmparser::collections::index_map::OccupiedEntry<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::key
322
323
    /// Gets a reference to the value in the entry.
324
    #[inline]
325
0
    pub fn get(&self) -> &V {
326
0
        self.inner.get()
327
0
    }
328
329
    /// Gets a mutable reference to the value in the entry.
330
    #[inline]
331
0
    pub fn get_mut(&mut self) -> &mut V {
332
0
        self.inner.get_mut()
333
0
    }
334
335
    /// Sets the value of the entry with the [`OccupiedEntry`]'s key, and returns the entry's old value.
336
    #[inline]
337
0
    pub fn insert(&mut self, value: V) -> V {
338
0
        self.inner.insert(value)
339
0
    }
340
341
    /// Converts the [`OccupiedEntry`] into a mutable reference to the value in the entry
342
    /// with a lifetime bound to the map itself.
343
    #[inline]
344
126k
    pub fn into_mut(self) -> &'a mut V {
345
126k
        self.inner.into_mut()
346
126k
    }
347
}
348
349
/// A view into a vacant entry in a [`IndexMap`].
350
///
351
/// It is part of the [`Entry`] enum.
352
#[derive(Debug)]
353
pub struct VacantEntry<'a, K: Ord, V> {
354
    inner: detail::VacantEntryImpl<'a, K, V>,
355
}
356
357
impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V>
358
where
359
    K: Ord + Clone,
360
{
361
    /// Gets a reference to the key in the entry.
362
    #[inline]
363
0
    pub fn key(&self) -> &K {
364
0
        self.inner.key()
365
0
    }
366
367
    /// Take ownership of the key.
368
    #[inline]
369
0
    pub fn into_key(self) -> K {
370
0
        self.inner.into_key()
371
0
    }
372
373
    /// Sets the value of the entry with the [`VacantEntry`]'s key, and returns a mutable reference to it.
374
    #[inline]
375
1.37M
    pub fn insert(self, value: V) -> &'a mut V
376
1.37M
    where
377
1.37M
        K: Hash,
378
    {
379
1.37M
        self.inner.insert(value)
380
1.37M
    }
<wasmparser::collections::index_map::VacantEntry<alloc::string::String, wasmparser::validator::component_types::ComponentItem>>::insert
Line
Count
Source
375
842k
    pub fn insert(self, value: V) -> &'a mut V
376
842k
    where
377
842k
        K: Hash,
378
    {
379
842k
        self.inner.insert(value)
380
842k
    }
<wasmparser::collections::index_map::VacantEntry<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::insert
Line
Count
Source
375
52.0k
    pub fn insert(self, value: V) -> &'a mut V
376
52.0k
    where
377
52.0k
        K: Hash,
378
    {
379
52.0k
        self.inner.insert(value)
380
52.0k
    }
<wasmparser::collections::index_map::VacantEntry<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::insert
Line
Count
Source
375
60.1k
    pub fn insert(self, value: V) -> &'a mut V
376
60.1k
    where
377
60.1k
        K: Hash,
378
    {
379
60.1k
        self.inner.insert(value)
380
60.1k
    }
<wasmparser::collections::index_map::VacantEntry<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::insert
Line
Count
Source
375
168k
    pub fn insert(self, value: V) -> &'a mut V
376
168k
    where
377
168k
        K: Hash,
378
    {
379
168k
        self.inner.insert(value)
380
168k
    }
<wasmparser::collections::index_map::VacantEntry<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>>::insert
Line
Count
Source
375
250k
    pub fn insert(self, value: V) -> &'a mut V
376
250k
    where
377
250k
        K: Hash,
378
    {
379
250k
        self.inner.insert(value)
380
250k
    }
381
}
382
383
impl<K, V> FromIterator<(K, V)> for IndexMap<K, V>
384
where
385
    K: Hash + Ord + Eq + Clone,
386
{
387
    #[inline]
388
61.8k
    fn from_iter<I>(iter: I) -> Self
389
61.8k
    where
390
61.8k
        I: IntoIterator<Item = (K, V)>,
391
    {
392
61.8k
        Self {
393
61.8k
            inner: <detail::IndexMapImpl<K, V>>::from_iter(iter),
394
61.8k
        }
395
61.8k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::iter::traits::collect::FromIterator<(alloc::string::String, wasmparser::validator::component_types::ComponentEntityType)>>::from_iter::<core::iter::adapters::map::Map<wasmparser::collections::index_map::Iter<alloc::string::String, wasmparser::validator::component_types::ComponentItem>, <wasmparser::validator::component_types::SubtypeCx>::component_type::{closure#2}::{closure#0}>>
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::iter::traits::collect::FromIterator<(alloc::string::String, wasmparser::validator::component_types::ComponentEntityType)>>::from_iter::<core::iter::adapters::map::Map<wasmparser::collections::index_map::Iter<alloc::string::String, wasmparser::validator::component_types::ComponentItem>, <wasmparser::validator::component_types::SubtypeCx>::component_type::{closure#0}>>
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()> as core::iter::traits::collect::FromIterator<(wasmparser::validator::component_types::ResourceId, ())>>::from_iter::<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <wasmparser::validator::component::ComponentState>::instantiate_component::{closure#0}>, <wasmparser::collections::index_set::IndexSet<wasmparser::validator::component_types::ResourceId> as core::iter::traits::collect::FromIterator<wasmparser::validator::component_types::ResourceId>>::from_iter<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <wasmparser::validator::component::ComponentState>::instantiate_component::{closure#0}>>::{closure#0}>>
Line
Count
Source
388
26.2k
    fn from_iter<I>(iter: I) -> Self
389
26.2k
    where
390
26.2k
        I: IntoIterator<Item = (K, V)>,
391
    {
392
26.2k
        Self {
393
26.2k
            inner: <detail::IndexMapImpl<K, V>>::from_iter(iter),
394
26.2k
        }
395
26.2k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::AliasableResourceId, ()> as core::iter::traits::collect::FromIterator<(wasmparser::validator::component_types::AliasableResourceId, ())>>::from_iter::<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <wasmparser::validator::component::ComponentState>::prepare_instance_import::{closure#0}>, <wasmparser::collections::index_set::IndexSet<wasmparser::validator::component_types::AliasableResourceId> as core::iter::traits::collect::FromIterator<wasmparser::validator::component_types::AliasableResourceId>>::from_iter<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <wasmparser::validator::component::ComponentState>::prepare_instance_import::{closure#0}>>::{closure#0}>>
Line
Count
Source
388
2.46k
    fn from_iter<I>(iter: I) -> Self
389
2.46k
    where
390
2.46k
        I: IntoIterator<Item = (K, V)>,
391
    {
392
2.46k
        Self {
393
2.46k
            inner: <detail::IndexMapImpl<K, V>>::from_iter(iter),
394
2.46k
        }
395
2.46k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), wasmparser::validator::types::EntityType> as core::iter::traits::collect::FromIterator<((alloc::string::String, alloc::string::String), wasmparser::validator::types::EntityType)>>::from_iter::<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<wasmparser::collections::index_map::Iter<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>, <wasmparser::validator::core::Module>::imports_for_module_type::{closure#0}>, core::result::Result<core::convert::Infallible, wasmparser::error::Error>>>
Line
Count
Source
388
33.1k
    fn from_iter<I>(iter: I) -> Self
389
33.1k
    where
390
33.1k
        I: IntoIterator<Item = (K, V)>,
391
    {
392
33.1k
        Self {
393
33.1k
            inner: <detail::IndexMapImpl<K, V>>::from_iter(iter),
394
33.1k
        }
395
33.1k
    }
396
}
397
398
impl<'a, K, V> IntoIterator for &'a IndexMap<K, V> {
399
    type Item = (&'a K, &'a V);
400
    type IntoIter = Iter<'a, K, V>;
401
402
    #[inline]
403
0
    fn into_iter(self) -> Self::IntoIter {
404
0
        self.iter()
405
0
    }
406
}
407
408
/// An iterator over the items of a [`IndexMap`].
409
#[derive(Debug, Clone)]
410
pub struct Iter<'a, K, V> {
411
    inner: detail::IterImpl<'a, K, V>,
412
}
413
414
impl<'a, K, V> Iterator for Iter<'a, K, V> {
415
    type Item = (&'a K, &'a V);
416
417
    #[inline]
418
114k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
114k
        self.inner.size_hint()
420
114k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase> as core::iter::traits::iterator::Iterator>::size_hint
Line
Count
Source
418
4.39k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
4.39k
        self.inner.size_hint()
420
4.39k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType> as core::iter::traits::iterator::Iterator>::size_hint
Line
Count
Source
418
7.58k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
7.58k
        self.inner.size_hint()
420
7.58k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::names::KebabString, ()> as core::iter::traits::iterator::Iterator>::size_hint
Line
Count
Source
418
36.4k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
36.4k
        self.inner.size_hint()
420
36.4k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::Iter<alloc::string::String, wasmparser::validator::component_types::ComponentItem> as core::iter::traits::iterator::Iterator>::size_hint
<wasmparser::collections::index_map::Iter<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>> as core::iter::traits::iterator::Iterator>::size_hint
Line
Count
Source
418
66.2k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
66.2k
        self.inner.size_hint()
420
66.2k
    }
421
422
    #[inline]
423
2.84M
    fn next(&mut self) -> Option<Self::Item> {
424
2.84M
        self.inner.next()
425
2.84M
    }
<wasmparser::collections::index_map::Iter<alloc::string::String, wasmparser::validator::component_types::ComponentItem> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
1.50M
    fn next(&mut self) -> Option<Self::Item> {
424
1.50M
        self.inner.next()
425
1.50M
    }
<wasmparser::collections::index_map::Iter<alloc::string::String, wasmparser::validator::types::EntityType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
211k
    fn next(&mut self) -> Option<Self::Item> {
424
211k
        self.inner.next()
425
211k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
158k
    fn next(&mut self) -> Option<Self::Item> {
424
158k
        self.inner.next()
425
158k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::Iter<wasmparser::validator::component_types::ResourceId, ()> as core::iter::traits::iterator::Iterator>::next
<wasmparser::collections::index_map::Iter<wasmparser::validator::component_types::AliasableResourceId, ()> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
2.87k
    fn next(&mut self) -> Option<Self::Item> {
424
2.87k
        self.inner.next()
425
2.87k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
40.7k
    fn next(&mut self) -> Option<Self::Item> {
424
40.7k
        self.inner.next()
425
40.7k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
111k
    fn next(&mut self) -> Option<Self::Item> {
424
111k
        self.inner.next()
425
111k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::names::KebabString, ()> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
380k
    fn next(&mut self) -> Option<Self::Item> {
424
380k
        self.inner.next()
425
380k
    }
<wasmparser::collections::index_map::Iter<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
219k
    fn next(&mut self) -> Option<Self::Item> {
424
219k
        self.inner.next()
425
219k
    }
<wasmparser::collections::index_map::Iter<(alloc::string::String, alloc::string::String), wasmparser::validator::types::EntityType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
219k
    fn next(&mut self) -> Option<Self::Item> {
424
219k
        self.inner.next()
425
219k
    }
426
}
427
428
impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> {
429
    #[inline]
430
0
    fn len(&self) -> usize {
431
0
        self.inner.len()
432
0
    }
433
}
434
435
impl<'a, K, V> FusedIterator for Iter<'a, K, V> {}
436
437
impl<'a, K, V> IntoIterator for &'a mut IndexMap<K, V> {
438
    type Item = (&'a K, &'a mut V);
439
    type IntoIter = IterMut<'a, K, V>;
440
441
    #[inline]
442
0
    fn into_iter(self) -> Self::IntoIter {
443
0
        self.iter_mut()
444
0
    }
445
}
446
447
/// An iterator over the mutable items of a [`IndexMap`].
448
#[derive(Debug)]
449
pub struct IterMut<'a, K, V> {
450
    inner: detail::IterMutImpl<'a, K, V>,
451
}
452
453
impl<'a, K, V> Iterator for IterMut<'a, K, V> {
454
    type Item = (&'a K, &'a mut V);
455
456
    #[inline]
457
0
    fn size_hint(&self) -> (usize, Option<usize>) {
458
0
        self.inner.size_hint()
459
0
    }
460
461
    #[inline]
462
0
    fn next(&mut self) -> Option<Self::Item> {
463
0
        self.inner.next()
464
0
    }
465
}
466
467
impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> {
468
    #[inline]
469
0
    fn len(&self) -> usize {
470
0
        self.inner.len()
471
0
    }
472
}
473
474
impl<'a, K, V> FusedIterator for IterMut<'a, K, V> {}
475
476
impl<K, V> IntoIterator for IndexMap<K, V> {
477
    type Item = (K, V);
478
    type IntoIter = IntoIter<K, V>;
479
480
    #[inline]
481
428k
    fn into_iter(self) -> Self::IntoIter {
482
428k
        IntoIter {
483
428k
            inner: self.inner.into_iter(),
484
428k
        }
485
428k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>> as core::iter::traits::collect::IntoIterator>::into_iter
Line
Count
Source
481
148k
    fn into_iter(self) -> Self::IntoIter {
482
148k
        IntoIter {
483
148k
            inner: self.inner.into_iter(),
484
148k
        }
485
148k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>> as core::iter::traits::collect::IntoIterator>::into_iter
Line
Count
Source
481
253k
    fn into_iter(self) -> Self::IntoIter {
482
253k
        IntoIter {
483
253k
            inner: self.inner.into_iter(),
484
253k
        }
485
253k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()> as core::iter::traits::collect::IntoIterator>::into_iter
Line
Count
Source
481
26.2k
    fn into_iter(self) -> Self::IntoIter {
482
26.2k
        IntoIter {
483
26.2k
            inner: self.inner.into_iter(),
484
26.2k
        }
485
26.2k
    }
486
}
487
488
/// An iterator over the owned items of an [`IndexMap`].
489
#[derive(Debug)]
490
pub struct IntoIter<K, V> {
491
    inner: detail::IntoIterImpl<K, V>,
492
}
493
494
impl<K, V> Iterator for IntoIter<K, V> {
495
    type Item = (K, V);
496
497
    #[inline]
498
19.7k
    fn size_hint(&self) -> (usize, Option<usize>) {
499
19.7k
        self.inner.size_hint()
500
19.7k
    }
<wasmparser::collections::index_map::IntoIter<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>> as core::iter::traits::iterator::Iterator>::size_hint
Line
Count
Source
498
6.91k
    fn size_hint(&self) -> (usize, Option<usize>) {
499
6.91k
        self.inner.size_hint()
500
6.91k
    }
<wasmparser::collections::index_map::IntoIter<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>> as core::iter::traits::iterator::Iterator>::size_hint
Line
Count
Source
498
12.8k
    fn size_hint(&self) -> (usize, Option<usize>) {
499
12.8k
        self.inner.size_hint()
500
12.8k
    }
501
502
    #[inline]
503
456k
    fn next(&mut self) -> Option<Self::Item> {
504
456k
        self.inner.next()
505
456k
    }
<wasmparser::collections::index_map::IntoIter<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
503
156k
    fn next(&mut self) -> Option<Self::Item> {
504
156k
        self.inner.next()
505
156k
    }
<wasmparser::collections::index_map::IntoIter<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
503
273k
    fn next(&mut self) -> Option<Self::Item> {
504
273k
        self.inner.next()
505
273k
    }
<wasmparser::collections::index_map::IntoIter<wasmparser::validator::component_types::ResourceId, ()> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
503
26.2k
    fn next(&mut self) -> Option<Self::Item> {
504
26.2k
        self.inner.next()
505
26.2k
    }
506
}
507
508
impl<K, V> ExactSizeIterator for IntoIter<K, V> {
509
    #[inline]
510
0
    fn len(&self) -> usize {
511
0
        self.inner.len()
512
0
    }
513
}
514
515
impl<K, V> FusedIterator for IntoIter<K, V> {}
516
517
/// An iterator over the keys of a [`IndexMap`].
518
#[derive(Debug, Clone)]
519
pub struct Keys<'a, K, V> {
520
    inner: detail::KeysImpl<'a, K, V>,
521
}
522
523
impl<'a, K, V> Iterator for Keys<'a, K, V> {
524
    type Item = &'a K;
525
526
    #[inline]
527
0
    fn size_hint(&self) -> (usize, Option<usize>) {
528
0
        self.inner.size_hint()
529
0
    }
530
531
    #[inline]
532
42.1k
    fn next(&mut self) -> Option<Self::Item> {
533
42.1k
        self.inner.next()
534
42.1k
    }
<wasmparser::collections::index_map::Keys<alloc::string::String, wasmparser::validator::component_types::ComponentItem> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
532
42.1k
    fn next(&mut self) -> Option<Self::Item> {
533
42.1k
        self.inner.next()
534
42.1k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::Keys<_, _> as core::iter::traits::iterator::Iterator>::next
535
}
536
537
impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {
538
    #[inline]
539
0
    fn len(&self) -> usize {
540
0
        self.inner.len()
541
0
    }
542
}
543
544
impl<'a, K, V> FusedIterator for Keys<'a, K, V> {}
545
546
/// An iterator over the values of a [`IndexMap`].
547
#[derive(Debug, Clone)]
548
pub struct Values<'a, K, V> {
549
    inner: detail::ValuesImpl<'a, K, V>,
550
}
551
552
impl<'a, K, V> Iterator for Values<'a, K, V> {
553
    type Item = &'a V;
554
555
    #[inline]
556
0
    fn size_hint(&self) -> (usize, Option<usize>) {
557
0
        self.inner.size_hint()
558
0
    }
559
560
    #[inline]
561
4.42M
    fn next(&mut self) -> Option<Self::Item> {
562
4.42M
        self.inner.next()
563
4.42M
    }
<wasmparser::collections::index_map::Values<alloc::string::String, wasmparser::validator::component_types::ComponentItem> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
561
2.90M
    fn next(&mut self) -> Option<Self::Item> {
562
2.90M
        self.inner.next()
563
2.90M
    }
<wasmparser::collections::index_map::Values<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
561
409k
    fn next(&mut self) -> Option<Self::Item> {
562
409k
        self.inner.next()
563
409k
    }
<wasmparser::collections::index_map::Values<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
561
1.10M
    fn next(&mut self) -> Option<Self::Item> {
562
1.10M
        self.inner.next()
563
1.10M
    }
564
}
565
566
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {
567
    #[inline]
568
12.0k
    fn len(&self) -> usize {
569
12.0k
        self.inner.len()
570
12.0k
    }
<wasmparser::collections::index_map::Values<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase> as core::iter::traits::exact_size::ExactSizeIterator>::len
Line
Count
Source
568
12.0k
    fn len(&self) -> usize {
569
12.0k
        self.inner.len()
570
12.0k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::Values<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType> as core::iter::traits::exact_size::ExactSizeIterator>::len
571
}
572
573
impl<'a, K, V> FusedIterator for Values<'a, K, V> {}
574
575
/// An mutable iterator over the values of a [`IndexMap`].
576
#[derive(Debug)]
577
pub struct ValuesMut<'a, K, V> {
578
    inner: detail::ValuesMutImpl<'a, K, V>,
579
}
580
581
impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
582
    type Item = &'a mut V;
583
584
    #[inline]
585
0
    fn size_hint(&self) -> (usize, Option<usize>) {
586
0
        self.inner.size_hint()
587
0
    }
588
589
    #[inline]
590
441k
    fn next(&mut self) -> Option<Self::Item> {
591
441k
        self.inner.next()
592
441k
    }
<wasmparser::collections::index_map::ValuesMut<alloc::string::String, wasmparser::validator::component_types::ComponentItem> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
590
285k
    fn next(&mut self) -> Option<Self::Item> {
591
285k
        self.inner.next()
592
285k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::ValuesMut<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::iter::traits::iterator::Iterator>::next
<wasmparser::collections::index_map::ValuesMut<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
590
39.3k
    fn next(&mut self) -> Option<Self::Item> {
591
39.3k
        self.inner.next()
592
39.3k
    }
<wasmparser::collections::index_map::ValuesMut<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
590
116k
    fn next(&mut self) -> Option<Self::Item> {
591
116k
        self.inner.next()
592
116k
    }
593
}
594
595
impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> {
596
    #[inline]
597
0
    fn len(&self) -> usize {
598
0
        self.inner.len()
599
0
    }
600
}
601
602
impl<'a, K, V> FusedIterator for ValuesMut<'a, K, V> {}
603
604
#[cfg(feature = "serde")]
605
impl<K, V> serde::Serialize for IndexMap<K, V>
606
where
607
    K: serde::Serialize + Eq + Hash + Ord,
608
    V: serde::Serialize,
609
{
610
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
611
    where
612
        S: serde::ser::Serializer,
613
    {
614
        serde::Serialize::serialize(&self.inner, serializer)
615
    }
616
}
617
618
#[cfg(feature = "serde")]
619
impl<'a, K, V> serde::Deserialize<'a> for IndexMap<K, V>
620
where
621
    K: serde::Deserialize<'a> + Eq + Hash + Ord + Clone,
622
    V: serde::Deserialize<'a>,
623
{
624
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
625
    where
626
        D: serde::de::Deserializer<'a>,
627
    {
628
        Ok(IndexMap {
629
            inner: serde::Deserialize::deserialize(deserializer)?,
630
        })
631
    }
632
}
633
634
impl<K, V> PartialEq for IndexMap<K, V>
635
where
636
    K: PartialEq + Hash + Ord,
637
    V: PartialEq,
638
{
639
0
    fn eq(&self, other: &Self) -> bool {
640
0
        self.inner == other.inner
641
0
    }
642
643
0
    fn ne(&self, other: &Self) -> bool {
644
0
        self.inner != other.inner
645
0
    }
646
}
647
648
impl<K, V> Eq for IndexMap<K, V>
649
where
650
    K: Eq + Hash + Ord,
651
    V: Eq,
652
{
653
}