Coverage Report

Created: 2026-04-24 07:45

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
2.46M
    fn default() -> Self {
27
2.46M
        Self {
28
2.46M
            inner: detail::IndexMapImpl::default(),
29
2.46M
        }
30
2.46M
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::default::Default>::default
Line
Count
Source
26
411k
    fn default() -> Self {
27
411k
        Self {
28
411k
            inner: detail::IndexMapImpl::default(),
29
411k
        }
30
411k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType> as core::default::Default>::default
Line
Count
Source
26
74.8k
    fn default() -> Self {
27
74.8k
        Self {
28
74.8k
            inner: detail::IndexMapImpl::default(),
29
74.8k
        }
30
74.8k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, ()> as core::default::Default>::default
Line
Count
Source
26
348k
    fn default() -> Self {
27
348k
        Self {
28
348k
            inner: detail::IndexMapImpl::default(),
29
348k
        }
30
348k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>> as core::default::Default>::default
Line
Count
Source
26
638k
    fn default() -> Self {
27
638k
        Self {
28
638k
            inner: detail::IndexMapImpl::default(),
29
638k
        }
30
638k
    }
<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
348k
    fn default() -> Self {
27
348k
        Self {
28
348k
            inner: detail::IndexMapImpl::default(),
29
348k
        }
30
348k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()> as core::default::Default>::default
Line
Count
Source
26
112k
    fn default() -> Self {
27
112k
        Self {
28
112k
            inner: detail::IndexMapImpl::default(),
29
112k
        }
30
112k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase> as core::default::Default>::default
Line
Count
Source
26
8.54k
    fn default() -> Self {
27
8.54k
        Self {
28
8.54k
            inner: detail::IndexMapImpl::default(),
29
8.54k
        }
30
8.54k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType> as core::default::Default>::default
Line
Count
Source
26
6.65k
    fn default() -> Self {
27
6.65k
        Self {
28
6.65k
            inner: detail::IndexMapImpl::default(),
29
6.65k
        }
30
6.65k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()> as core::default::Default>::default
Line
Count
Source
26
31.4k
    fn default() -> Self {
27
31.4k
        Self {
28
31.4k
            inner: detail::IndexMapImpl::default(),
29
31.4k
        }
30
31.4k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::ComponentName, ()> as core::default::Default>::default
Line
Count
Source
26
348k
    fn default() -> Self {
27
348k
        Self {
28
348k
            inner: detail::IndexMapImpl::default(),
29
348k
        }
30
348k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::types::CoreTypeId, u8> as core::default::Default>::default
Line
Count
Source
26
54.0k
    fn default() -> Self {
27
54.0k
        Self {
28
54.0k
            inner: detail::IndexMapImpl::default(),
29
54.0k
        }
30
54.0k
    }
<wasmparser::collections::index_map::IndexMap<&str, &wasmparser::validator::component_types::InstanceType> as core::default::Default>::default
Line
Count
Source
26
27.0k
    fn default() -> Self {
27
27.0k
        Self {
28
27.0k
            inner: detail::IndexMapImpl::default(),
29
27.0k
        }
30
27.0k
    }
<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
55.1k
    fn default() -> Self {
27
55.1k
        Self {
28
55.1k
            inner: detail::IndexMapImpl::default(),
29
55.1k
        }
30
55.1k
    }
31
}
32
33
impl<K, V> IndexMap<K, V> {
34
    /// Clears the [`IndexMap`], removing all elements.
35
    #[inline]
36
112k
    pub fn clear(&mut self) {
37
112k
        self.inner.clear()
38
112k
    }
39
40
    /// Returns the number of elements in the [`IndexMap`].
41
    #[inline]
42
341k
    pub fn len(&self) -> usize {
43
341k
        self.inner.len()
44
341k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::len
Line
Count
Source
42
268k
    pub fn len(&self) -> usize {
43
268k
        self.inner.len()
44
268k
    }
<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
6.36k
    pub fn len(&self) -> usize {
43
6.36k
        self.inner.len()
44
6.36k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::len
Line
Count
Source
42
1.55k
    pub fn len(&self) -> usize {
43
1.55k
        self.inner.len()
44
1.55k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::len
Line
Count
Source
42
936
    pub fn len(&self) -> usize {
43
936
        self.inner.len()
44
936
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()>>::len
Line
Count
Source
42
177
    pub fn len(&self) -> usize {
43
177
        self.inner.len()
44
177
    }
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
35.1k
    pub fn len(&self) -> usize {
43
35.1k
        self.inner.len()
44
35.1k
    }
45
46
    /// Returns `true` if the [`IndexMap`] contains no elements.
47
    #[inline]
48
61.5k
    pub fn is_empty(&self) -> bool {
49
61.5k
        self.inner.is_empty()
50
61.5k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>>>::is_empty
Line
Count
Source
48
61.5k
    pub fn is_empty(&self) -> bool {
49
61.5k
        self.inner.is_empty()
50
61.5k
    }
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
433k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
433k
        Iter {
56
433k
            inner: self.inner.iter(),
57
433k
        }
58
433k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::iter
Line
Count
Source
54
156k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
156k
        Iter {
56
156k
            inner: self.inner.iter(),
57
156k
        }
58
156k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType>>::iter
Line
Count
Source
54
27.0k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
27.0k
        Iter {
56
27.0k
            inner: self.inner.iter(),
57
27.0k
        }
58
27.0k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>>>::iter
Line
Count
Source
54
53.2k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
53.2k
        Iter {
56
53.2k
            inner: self.inner.iter(),
57
53.2k
        }
58
53.2k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>>>::iter
Line
Count
Source
54
112k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
112k
        Iter {
56
112k
            inner: self.inner.iter(),
57
112k
        }
58
112k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()>>::iter
Line
Count
Source
54
1.17k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
1.17k
        Iter {
56
1.17k
            inner: self.inner.iter(),
57
1.17k
        }
58
1.17k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::AliasableResourceId, ()>>::iter
Line
Count
Source
54
1.11k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
1.11k
        Iter {
56
1.11k
            inner: self.inner.iter(),
57
1.11k
        }
58
1.11k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::iter
Line
Count
Source
54
5.12k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
5.12k
        Iter {
56
5.12k
            inner: self.inner.iter(),
57
5.12k
        }
58
5.12k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::iter
Line
Count
Source
54
4.11k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
4.11k
        Iter {
56
4.11k
            inner: self.inner.iter(),
57
4.11k
        }
58
4.11k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()>>::iter
Line
Count
Source
54
18.1k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
18.1k
        Iter {
56
18.1k
            inner: self.inner.iter(),
57
18.1k
        }
58
18.1k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>>::iter
Line
Count
Source
54
27.0k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
27.0k
        Iter {
56
27.0k
            inner: self.inner.iter(),
57
27.0k
        }
58
27.0k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), wasmparser::validator::types::EntityType>>::iter
Line
Count
Source
54
27.0k
    pub fn iter(&self) -> Iter<'_, K, V> {
55
27.0k
        Iter {
56
27.0k
            inner: self.inner.iter(),
57
27.0k
        }
58
27.0k
    }
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
41.6k
    pub fn keys(&self) -> Keys<'_, K, V> {
71
41.6k
        Keys {
72
41.6k
            inner: self.inner.keys(),
73
41.6k
        }
74
41.6k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::keys
Line
Count
Source
70
41.6k
    pub fn keys(&self) -> Keys<'_, K, V> {
71
41.6k
        Keys {
72
41.6k
            inner: self.inner.keys(),
73
41.6k
        }
74
41.6k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::IndexMap<_, _>>::keys
75
76
    /// Returns an iterator that yields the values in the [`IndexMap`].
77
    #[inline]
78
657k
    pub fn values(&self) -> Values<'_, K, V> {
79
657k
        Values {
80
657k
            inner: self.inner.values(),
81
657k
        }
82
657k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::values
Line
Count
Source
78
561k
    pub fn values(&self) -> Values<'_, K, V> {
79
561k
        Values {
80
561k
            inner: self.inner.values(),
81
561k
        }
82
561k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::values
Line
Count
Source
78
51.9k
    pub fn values(&self) -> Values<'_, K, V> {
79
51.9k
        Values {
80
51.9k
            inner: self.inner.values(),
81
51.9k
        }
82
51.9k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::values
Line
Count
Source
78
43.8k
    pub fn values(&self) -> Values<'_, K, V> {
79
43.8k
        Values {
80
43.8k
            inner: self.inner.values(),
81
43.8k
        }
82
43.8k
    }
83
84
    /// Returns a mutable iterator that yields the values in the [`IndexMap`].
85
    #[inline]
86
6.70k
    pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
87
6.70k
        ValuesMut {
88
6.70k
            inner: self.inner.values_mut(),
89
6.70k
        }
90
6.70k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::values_mut
Line
Count
Source
86
3.39k
    pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
87
3.39k
        ValuesMut {
88
3.39k
            inner: self.inner.values_mut(),
89
3.39k
        }
90
3.39k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::values_mut
Line
Count
Source
86
1.96k
    pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
87
1.96k
        ValuesMut {
88
1.96k
            inner: self.inner.values_mut(),
89
1.96k
        }
90
1.96k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::values_mut
Line
Count
Source
86
1.35k
    pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
87
1.35k
        ValuesMut {
88
1.35k
            inner: self.inner.values_mut(),
89
1.35k
        }
90
1.35k
    }
91
92
    /// Returns the key-value entry at the given `index` if any.
93
    #[inline]
94
4.93k
    pub fn get_index(&self, index: usize) -> Option<(&K, &V)> {
95
4.93k
        self.inner.get_index(index)
96
4.93k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::get_index
Line
Count
Source
94
279
    pub fn get_index(&self, index: usize) -> Option<(&K, &V)> {
95
279
        self.inner.get_index(index)
96
279
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, ()>>::get_index
Line
Count
Source
94
4.65k
    pub fn get_index(&self, index: usize) -> Option<(&K, &V)> {
95
4.65k
        self.inner.get_index(index)
96
4.65k
    }
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
182k
    pub fn reserve(&mut self, additional: usize) {
112
182k
        self.inner.reserve(additional);
113
182k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::reserve
Line
Count
Source
111
72.6k
    pub fn reserve(&mut self, additional: usize) {
112
72.6k
        self.inner.reserve(additional);
113
72.6k
    }
<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
8.54k
    pub fn reserve(&mut self, additional: usize) {
112
8.54k
        self.inner.reserve(additional);
113
8.54k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::reserve
Line
Count
Source
111
6.65k
    pub fn reserve(&mut self, additional: usize) {
112
6.65k
        self.inner.reserve(additional);
113
6.65k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()>>::reserve
Line
Count
Source
111
31.4k
    pub fn reserve(&mut self, additional: usize) {
112
31.4k
        self.inner.reserve(additional);
113
31.4k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>>::reserve
Line
Count
Source
111
35.1k
    pub fn reserve(&mut self, additional: usize) {
112
35.1k
        self.inner.reserve(additional);
113
35.1k
    }
114
115
    /// Returns true if `key` is contains in the [`IndexMap`].
116
    #[inline]
117
5.33k
    pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
118
5.33k
    where
119
5.33k
        K: Borrow<Q>,
120
5.33k
        Q: Hash + Eq + Ord,
121
    {
122
5.33k
        self.inner.contains_key(key)
123
5.33k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, ()>>::contains_key::<str>
Line
Count
Source
117
2.15k
    pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
118
2.15k
    where
119
2.15k
        K: Borrow<Q>,
120
2.15k
        Q: Hash + Eq + Ord,
121
    {
122
2.15k
        self.inner.contains_key(key)
123
2.15k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()>>::contains_key::<wasmparser::validator::component_types::ResourceId>
Line
Count
Source
117
3.17k
    pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
118
3.17k
    where
119
3.17k
        K: Borrow<Q>,
120
3.17k
        Q: Hash + Eq + Ord,
121
    {
122
3.17k
        self.inner.contains_key(key)
123
3.17k
    }
124
125
    /// Returns a reference to the value corresponding to the `key`.
126
    #[inline]
127
172k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
172k
    where
129
172k
        K: Borrow<Q>,
130
172k
        Q: Hash + Eq + Ord,
131
    {
132
172k
        self.inner.get(key)
133
172k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::get::<alloc::string::String>
Line
Count
Source
127
3.04k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
3.04k
    where
129
3.04k
        K: Borrow<Q>,
130
3.04k
        Q: Hash + Eq + Ord,
131
    {
132
3.04k
        self.inner.get(key)
133
3.04k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::get::<str>
Line
Count
Source
127
23.4k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
23.4k
    where
129
23.4k
        K: Borrow<Q>,
130
23.4k
        Q: Hash + Eq + Ord,
131
    {
132
23.4k
        self.inner.get(key)
133
23.4k
    }
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
91.5k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
91.5k
    where
129
91.5k
        K: Borrow<Q>,
130
91.5k
        Q: Hash + Eq + Ord,
131
    {
132
91.5k
        self.inner.get(key)
133
91.5k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>>>::get::<wasmparser::validator::component_types::ResourceId>
Line
Count
Source
127
1.58k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
1.58k
    where
129
1.58k
        K: Borrow<Q>,
130
1.58k
        Q: Hash + Eq + Ord,
131
    {
132
1.58k
        self.inner.get(key)
133
1.58k
    }
<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
498
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
498
    where
129
498
        K: Borrow<Q>,
130
498
        Q: Hash + Eq + Ord,
131
    {
132
498
        self.inner.get(key)
133
498
    }
<wasmparser::collections::index_map::IndexMap<&str, &wasmparser::validator::component_types::InstanceType>>::get::<str>
Line
Count
Source
127
51.9k
    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
128
51.9k
    where
129
51.9k
        K: Borrow<Q>,
130
51.9k
        Q: Hash + Eq + Ord,
131
    {
132
51.9k
        self.inner.get(key)
133
51.9k
    }
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
1.01M
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
1.01M
        self.inner.insert(key, value)
181
1.01M
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::types::EntityType>>::insert
Line
Count
Source
179
191k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
191k
        self.inner.insert(key, value)
181
191k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, ()>>::insert
Line
Count
Source
179
6.36k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
6.36k
        self.inner.insert(key, value)
181
6.36k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>>>::insert
Line
Count
Source
179
12.1k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
12.1k
        self.inner.insert(key, value)
181
12.1k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, core::option::Option<wasmparser::readers::core::types::ValType>>>::insert
Line
Count
Source
179
4.32k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
4.32k
        self.inner.insert(key, value)
181
4.32k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()>>::insert
Line
Count
Source
179
27.5k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
27.5k
        self.inner.insert(key, value)
181
27.5k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, ()>>::insert
Line
Count
Source
179
148k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
148k
        self.inner.insert(key, value)
181
148k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::ComponentName, ()>>::insert
Line
Count
Source
179
262k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
262k
        self.inner.insert(key, value)
181
262k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::types::CoreTypeId, u8>>::insert
Line
Count
Source
179
337k
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
180
337k
        self.inner.insert(key, value)
181
337k
    }
<wasmparser::collections::index_map::IndexMap<&str, &wasmparser::validator::component_types::InstanceType>>::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
    }
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
5.01k
    pub fn swap_remove<Q>(&mut self, key: &Q) -> Option<V>
194
5.01k
    where
195
5.01k
        K: Borrow<Q>,
196
5.01k
        Q: ?Sized + Hash + Eq + Ord,
197
    {
198
5.01k
        self.inner.swap_remove(key)
199
5.01k
    }
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
262k
    pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
212
262k
    where
213
262k
        K: Borrow<Q>,
214
262k
        Q: ?Sized + Hash + Eq + Ord,
215
    {
216
262k
        self.inner.swap_remove_entry(key)
217
262k
    }
218
219
    /// Gets the given key's corresponding entry in the [`IndexMap`] for in-place manipulation.
220
    #[inline]
221
516k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
516k
        match self.inner.entry(key) {
223
109k
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
406k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
516k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::entry
Line
Count
Source
221
265k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
265k
        match self.inner.entry(key) {
223
0
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
265k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
265k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::entry
Line
Count
Source
221
31.3k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
31.3k
        match self.inner.entry(key) {
223
0
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
31.3k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
31.3k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::entry
Line
Count
Source
221
19.8k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
19.8k
        match self.inner.entry(key) {
223
0
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
19.8k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
19.8k
    }
<wasmparser::collections::index_map::IndexMap<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>>::entry
Line
Count
Source
221
199k
    pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
222
199k
        match self.inner.entry(key) {
223
109k
            detail::EntryImpl::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }),
224
90.2k
            detail::EntryImpl::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }),
225
        }
226
199k
    }
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
139k
    fn index(&self, key: &Q) -> &V {
238
139k
        &self.inner[key]
239
139k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::ops::index::Index<&alloc::string::String>>::index
Line
Count
Source
237
37.9k
    fn index(&self, key: &Q) -> &V {
238
37.9k
        &self.inner[key]
239
37.9k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>> as core::ops::index::Index<&wasmparser::validator::component_types::ResourceId>>::index
Line
Count
Source
237
1.39k
    fn index(&self, key: &Q) -> &V {
238
1.39k
        &self.inner[key]
239
1.39k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::types::CoreTypeId, u8> as core::ops::index::Index<&wasmparser::validator::types::CoreTypeId>>::index
Line
Count
Source
237
100k
    fn index(&self, key: &Q) -> &V {
238
100k
        &self.inner[key]
239
100k
    }
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
3.74k
    fn index(&self, key: usize) -> &V {
250
3.74k
        &self.inner[key]
251
3.74k
    }
<wasmparser::collections::index_map::IndexMap<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::ops::index::Index<usize>>::index
Line
Count
Source
249
3.74k
    fn index(&self, key: usize) -> &V {
250
3.74k
        &self.inner[key]
251
3.74k
    }
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
199k
    pub fn or_default(self) -> &'a mut V {
298
199k
        match self {
299
109k
            Self::Occupied(entry) => entry.into_mut(),
300
90.2k
            Self::Vacant(entry) => entry.insert(Default::default()),
301
        }
302
199k
    }
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::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
109k
    pub fn into_mut(self) -> &'a mut V {
345
109k
        self.inner.into_mut()
346
109k
    }
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
406k
    pub fn insert(self, value: V) -> &'a mut V
376
406k
    where
377
406k
        K: Hash,
378
    {
379
406k
        self.inner.insert(value)
380
406k
    }
<wasmparser::collections::index_map::VacantEntry<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType>>::insert
Line
Count
Source
375
265k
    pub fn insert(self, value: V) -> &'a mut V
376
265k
    where
377
265k
        K: Hash,
378
    {
379
265k
        self.inner.insert(value)
380
265k
    }
<wasmparser::collections::index_map::VacantEntry<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::VariantCase>>::insert
Line
Count
Source
375
31.3k
    pub fn insert(self, value: V) -> &'a mut V
376
31.3k
    where
377
31.3k
        K: Hash,
378
    {
379
31.3k
        self.inner.insert(value)
380
31.3k
    }
<wasmparser::collections::index_map::VacantEntry<wasmparser::validator::names::KebabString, wasmparser::validator::component_types::ComponentValType>>::insert
Line
Count
Source
375
19.8k
    pub fn insert(self, value: V) -> &'a mut V
376
19.8k
    where
377
19.8k
        K: Hash,
378
    {
379
19.8k
        self.inner.insert(value)
380
19.8k
    }
<wasmparser::collections::index_map::VacantEntry<(alloc::string::String, alloc::string::String), alloc::vec::Vec<wasmparser::validator::types::EntityType>>>::insert
Line
Count
Source
375
90.2k
    pub fn insert(self, value: V) -> &'a mut V
376
90.2k
    where
377
90.2k
        K: Hash,
378
    {
379
90.2k
        self.inner.insert(value)
380
90.2k
    }
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
30.4k
    fn from_iter<I>(iter: I) -> Self
389
30.4k
    where
390
30.4k
        I: IntoIterator<Item = (K, V)>,
391
    {
392
30.4k
        Self {
393
30.4k
            inner: <detail::IndexMapImpl<K, V>>::from_iter(iter),
394
30.4k
        }
395
30.4k
    }
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::ComponentEntityType>, <wasmparser::validator::component_types::SubtypeCx>::component_type::{closure#1}::{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::ComponentEntityType>, <wasmparser::validator::component_types::SubtypeCx>::component_type::{closure#0}>>
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>> as core::iter::traits::collect::FromIterator<(wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>)>>::from_iter::<core::iter::adapters::map::Map<wasmparser::collections::index_map::Iter<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>>, <wasmparser::validator::component::ComponentState>::instantiate_component::{closure#1}>>
Line
Count
Source
388
1.17k
    fn from_iter<I>(iter: I) -> Self
389
1.17k
    where
390
1.17k
        I: IntoIterator<Item = (K, V)>,
391
    {
392
1.17k
        Self {
393
1.17k
            inner: <detail::IndexMapImpl<K, V>>::from_iter(iter),
394
1.17k
        }
395
1.17k
    }
<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
1.17k
    fn from_iter<I>(iter: I) -> Self
389
1.17k
    where
390
1.17k
        I: IntoIterator<Item = (K, V)>,
391
    {
392
1.17k
        Self {
393
1.17k
            inner: <detail::IndexMapImpl<K, V>>::from_iter(iter),
394
1.17k
        }
395
1.17k
    }
<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
1.11k
    fn from_iter<I>(iter: I) -> Self
389
1.11k
    where
390
1.11k
        I: IntoIterator<Item = (K, V)>,
391
    {
392
1.11k
        Self {
393
1.11k
            inner: <detail::IndexMapImpl<K, V>>::from_iter(iter),
394
1.11k
        }
395
1.11k
    }
<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::binary_reader::BinaryReaderError>>>
Line
Count
Source
388
27.0k
    fn from_iter<I>(iter: I) -> Self
389
27.0k
    where
390
27.0k
        I: IntoIterator<Item = (K, V)>,
391
    {
392
27.0k
        Self {
393
27.0k
            inner: <detail::IndexMapImpl<K, V>>::from_iter(iter),
394
27.0k
        }
395
27.0k
    }
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
83.0k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
83.0k
        self.inner.size_hint()
420
83.0k
    }
<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.76k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
4.76k
        self.inner.size_hint()
420
4.76k
    }
<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
3.88k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
3.88k
        self.inner.size_hint()
420
3.88k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::names::KebabString, ()> as core::iter::traits::iterator::Iterator>::size_hint
Line
Count
Source
418
17.9k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
17.9k
        self.inner.size_hint()
420
17.9k
    }
Unexecuted instantiation: <wasmparser::collections::index_map::Iter<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::iter::traits::iterator::Iterator>::size_hint
<wasmparser::collections::index_map::Iter<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>> as core::iter::traits::iterator::Iterator>::size_hint
Line
Count
Source
418
2.35k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
2.35k
        self.inner.size_hint()
420
2.35k
    }
<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
54.0k
    fn size_hint(&self) -> (usize, Option<usize>) {
419
54.0k
        self.inner.size_hint()
420
54.0k
    }
421
422
    #[inline]
423
856k
    fn next(&mut self) -> Option<Self::Item> {
424
856k
        self.inner.next()
425
856k
    }
<wasmparser::collections::index_map::Iter<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
304k
    fn next(&mut self) -> Option<Self::Item> {
424
304k
        self.inner.next()
425
304k
    }
<wasmparser::collections::index_map::Iter<alloc::string::String, wasmparser::validator::types::EntityType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
75.6k
    fn next(&mut self) -> Option<Self::Item> {
424
75.6k
        self.inner.next()
425
75.6k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::component_types::ResourceId, alloc::vec::Vec<usize>> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
55.5k
    fn next(&mut self) -> Option<Self::Item> {
424
55.5k
        self.inner.next()
425
55.5k
    }
<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
114k
    fn next(&mut self) -> Option<Self::Item> {
424
114k
        self.inner.next()
425
114k
    }
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
1.39k
    fn next(&mut self) -> Option<Self::Item> {
424
1.39k
        self.inner.next()
425
1.39k
    }
<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
23.6k
    fn next(&mut self) -> Option<Self::Item> {
424
23.6k
        self.inner.next()
425
23.6k
    }
<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
16.5k
    fn next(&mut self) -> Option<Self::Item> {
424
16.5k
        self.inner.next()
425
16.5k
    }
<wasmparser::collections::index_map::Iter<wasmparser::validator::names::KebabString, ()> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
423
106k
    fn next(&mut self) -> Option<Self::Item> {
424
106k
        self.inner.next()
425
106k
    }
<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
78.9k
    fn next(&mut self) -> Option<Self::Item> {
424
78.9k
        self.inner.next()
425
78.9k
    }
<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
78.9k
    fn next(&mut self) -> Option<Self::Item> {
424
78.9k
        self.inner.next()
425
78.9k
    }
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
290k
    fn into_iter(self) -> Self::IntoIter {
482
290k
        IntoIter {
483
290k
            inner: self.inner.into_iter(),
484
290k
        }
485
290k
    }
<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
115k
    fn into_iter(self) -> Self::IntoIter {
482
115k
        IntoIter {
483
115k
            inner: self.inner.into_iter(),
484
115k
        }
485
115k
    }
<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
174k
    fn into_iter(self) -> Self::IntoIter {
482
174k
        IntoIter {
483
174k
            inner: self.inner.into_iter(),
484
174k
        }
485
174k
    }
<wasmparser::collections::index_map::IndexMap<wasmparser::validator::component_types::ResourceId, ()> as core::iter::traits::collect::IntoIterator>::into_iter
Line
Count
Source
481
1.17k
    fn into_iter(self) -> Self::IntoIter {
482
1.17k
        IntoIter {
483
1.17k
            inner: self.inner.into_iter(),
484
1.17k
        }
485
1.17k
    }
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
4.71k
    fn size_hint(&self) -> (usize, Option<usize>) {
499
4.71k
        self.inner.size_hint()
500
4.71k
    }
<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
2.49k
    fn size_hint(&self) -> (usize, Option<usize>) {
499
2.49k
        self.inner.size_hint()
500
2.49k
    }
<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
2.21k
    fn size_hint(&self) -> (usize, Option<usize>) {
499
2.21k
        self.inner.size_hint()
500
2.21k
    }
501
502
    #[inline]
503
300k
    fn next(&mut self) -> Option<Self::Item> {
504
300k
        self.inner.next()
505
300k
    }
<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
120k
    fn next(&mut self) -> Option<Self::Item> {
504
120k
        self.inner.next()
505
120k
    }
<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
178k
    fn next(&mut self) -> Option<Self::Item> {
504
178k
        self.inner.next()
505
178k
    }
<wasmparser::collections::index_map::IntoIter<wasmparser::validator::component_types::ResourceId, ()> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
503
1.17k
    fn next(&mut self) -> Option<Self::Item> {
504
1.17k
        self.inner.next()
505
1.17k
    }
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
41.6k
    fn next(&mut self) -> Option<Self::Item> {
533
41.6k
        self.inner.next()
534
41.6k
    }
<wasmparser::collections::index_map::Keys<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
532
41.6k
    fn next(&mut self) -> Option<Self::Item> {
533
41.6k
        self.inner.next()
534
41.6k
    }
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
1.49M
    fn next(&mut self) -> Option<Self::Item> {
562
1.49M
        self.inner.next()
563
1.49M
    }
<wasmparser::collections::index_map::Values<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
561
1.03M
    fn next(&mut self) -> Option<Self::Item> {
562
1.03M
        self.inner.next()
563
1.03M
    }
<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
268k
    fn next(&mut self) -> Option<Self::Item> {
562
268k
        self.inner.next()
563
268k
    }
<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
186k
    fn next(&mut self) -> Option<Self::Item> {
562
186k
        self.inner.next()
563
186k
    }
564
}
565
566
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {
567
    #[inline]
568
0
    fn len(&self) -> usize {
569
0
        self.inner.len()
570
0
    }
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
31.9k
    fn next(&mut self) -> Option<Self::Item> {
591
31.9k
        self.inner.next()
592
31.9k
    }
<wasmparser::collections::index_map::ValuesMut<alloc::string::String, wasmparser::validator::component_types::ComponentEntityType> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
590
18.3k
    fn next(&mut self) -> Option<Self::Item> {
591
18.3k
        self.inner.next()
592
18.3k
    }
<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
8.23k
    fn next(&mut self) -> Option<Self::Item> {
591
8.23k
        self.inner.next()
592
8.23k
    }
<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
5.39k
    fn next(&mut self) -> Option<Self::Item> {
591
5.39k
        self.inner.next()
592
5.39k
    }
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
}