/rust/registry/src/index.crates.io-6f17d22bba15001f/cranelift-entity-0.91.1/src/iter.rs
Line | Count | Source (jump to first uncovered line) |
1 | | //! A double-ended iterator over entity references and entities. |
2 | | |
3 | | use crate::EntityRef; |
4 | | use alloc::vec; |
5 | | use core::iter::Enumerate; |
6 | | use core::marker::PhantomData; |
7 | | use core::slice; |
8 | | |
9 | | /// Iterate over all keys in order. |
10 | | pub struct Iter<'a, K: EntityRef, V> |
11 | | where |
12 | | V: 'a, |
13 | | { |
14 | | enumerate: Enumerate<slice::Iter<'a, V>>, |
15 | | unused: PhantomData<K>, |
16 | | } |
17 | | |
18 | | impl<'a, K: EntityRef, V> Iter<'a, K, V> { |
19 | | /// Create an `Iter` iterator that visits the `PrimaryMap` keys and values |
20 | | /// of `iter`. |
21 | 4.88M | pub fn new(iter: slice::Iter<'a, V>) -> Self { |
22 | 4.88M | Self { |
23 | 4.88M | enumerate: iter.enumerate(), |
24 | 4.88M | unused: PhantomData, |
25 | 4.88M | } |
26 | 4.88M | } <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Block, cranelift_codegen::remove_constant_phis::BlockSummary>>::new Line | Count | Source | 21 | 139k | pub fn new(iter: slice::Iter<'a, V>) -> Self { | 22 | 139k | Self { | 23 | 139k | enumerate: iter.enumerate(), | 24 | 139k | unused: PhantomData, | 25 | 139k | } | 26 | 139k | } |
<cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::DynamicType, cranelift_codegen::ir::dynamic_type::DynamicTypeData>>::new Line | Count | Source | 21 | 139k | pub fn new(iter: slice::Iter<'a, V>) -> Self { | 22 | 139k | Self { | 23 | 139k | enumerate: iter.enumerate(), | 24 | 139k | unused: PhantomData, | 25 | 139k | } | 26 | 139k | } |
<cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::DynamicStackSlot, cranelift_codegen::ir::stackslot::DynamicStackSlotData>>::new Line | Count | Source | 21 | 139k | pub fn new(iter: slice::Iter<'a, V>) -> Self { | 22 | 139k | Self { | 23 | 139k | enumerate: iter.enumerate(), | 24 | 139k | unused: PhantomData, | 25 | 139k | } | 26 | 139k | } |
Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Value, cranelift_codegen::ir::dfg::ValueDataPacked>>::new Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::FuncRef, cranelift_codegen::ir::extfunc::ExtFuncData>>::new <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::StackSlot, cranelift_codegen::ir::stackslot::StackSlotData>>::new Line | Count | Source | 21 | 139k | pub fn new(iter: slice::Iter<'a, V>) -> Self { | 22 | 139k | Self { | 23 | 139k | enumerate: iter.enumerate(), | 24 | 139k | unused: PhantomData, | 25 | 139k | } | 26 | 139k | } |
<cranelift_entity::iter::Iter<cranelift_codegen::machinst::vcode::VCodeConstant, cranelift_codegen::machinst::vcode::VCodeConstantData>>::new Line | Count | Source | 21 | 139k | pub fn new(iter: slice::Iter<'a, V>) -> Self { | 22 | 139k | Self { | 23 | 139k | enumerate: iter.enumerate(), | 24 | 139k | unused: PhantomData, | 25 | 139k | } | 26 | 139k | } |
Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_egraph::Id, cranelift_egraph::EClass>>::new Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::GlobalValue, cranelift_codegen::ir::globalvalue::GlobalValueData>>::new <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Heap, cranelift_codegen::ir::heap::HeapData>>::new Line | Count | Source | 21 | 1.39M | pub fn new(iter: slice::Iter<'a, V>) -> Self { | 22 | 1.39M | Self { | 23 | 1.39M | enumerate: iter.enumerate(), | 24 | 1.39M | unused: PhantomData, | 25 | 1.39M | } | 26 | 1.39M | } |
<cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Table, cranelift_codegen::ir::table::TableData>>::new Line | Count | Source | 21 | 1.39M | pub fn new(iter: slice::Iter<'a, V>) -> Self { | 22 | 1.39M | Self { | 23 | 1.39M | enumerate: iter.enumerate(), | 24 | 1.39M | unused: PhantomData, | 25 | 1.39M | } | 26 | 1.39M | } |
Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::SigRef, cranelift_codegen::ir::extfunc::Signature>>::new <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::JumpTable, cranelift_codegen::ir::jumptable::JumpTableData>>::new Line | Count | Source | 21 | 1.39M | pub fn new(iter: slice::Iter<'a, V>) -> Self { | 22 | 1.39M | Self { | 23 | 1.39M | enumerate: iter.enumerate(), | 24 | 1.39M | unused: PhantomData, | 25 | 1.39M | } | 26 | 1.39M | } |
|
27 | | } |
28 | | |
29 | | impl<'a, K: EntityRef, V> Iterator for Iter<'a, K, V> { |
30 | | type Item = (K, &'a V); |
31 | | |
32 | 5.15M | fn next(&mut self) -> Option<Self::Item> { |
33 | 5.15M | self.enumerate.next().map(|(i, v)| (K::new(i), v)) Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_egraph::Id, cranelift_egraph::EClass> as core::iter::traits::iterator::Iterator>::next::{closure#0} Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::DynamicType, cranelift_codegen::ir::dynamic_type::DynamicTypeData> as core::iter::traits::iterator::Iterator>::next::{closure#0} Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::GlobalValue, cranelift_codegen::ir::globalvalue::GlobalValueData> as core::iter::traits::iterator::Iterator>::next::{closure#0} Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::DynamicStackSlot, cranelift_codegen::ir::stackslot::DynamicStackSlotData> as core::iter::traits::iterator::Iterator>::next::{closure#0} <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Heap, cranelift_codegen::ir::heap::HeapData> as core::iter::traits::iterator::Iterator>::next::{closure#0} Line | Count | Source | 33 | 66.8k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) |
<cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Block, cranelift_codegen::remove_constant_phis::BlockSummary> as core::iter::traits::iterator::Iterator>::next::{closure#0} Line | Count | Source | 33 | 153k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) |
<cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Table, cranelift_codegen::ir::table::TableData> as core::iter::traits::iterator::Iterator>::next::{closure#0} Line | Count | Source | 33 | 5.04k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) |
Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Value, cranelift_codegen::ir::dfg::ValueDataPacked> as core::iter::traits::iterator::Iterator>::next::{closure#0} Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::SigRef, cranelift_codegen::ir::extfunc::Signature> as core::iter::traits::iterator::Iterator>::next::{closure#0} Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::FuncRef, cranelift_codegen::ir::extfunc::ExtFuncData> as core::iter::traits::iterator::Iterator>::next::{closure#0} <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::JumpTable, cranelift_codegen::ir::jumptable::JumpTableData> as core::iter::traits::iterator::Iterator>::next::{closure#0} Line | Count | Source | 33 | 8.42k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) |
Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::StackSlot, cranelift_codegen::ir::stackslot::StackSlotData> as core::iter::traits::iterator::Iterator>::next::{closure#0} <cranelift_entity::iter::Iter<cranelift_codegen::machinst::vcode::VCodeConstant, cranelift_codegen::machinst::vcode::VCodeConstantData> as core::iter::traits::iterator::Iterator>::next::{closure#0} Line | Count | Source | 33 | 37.2k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) |
|
34 | 5.15M | } Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_egraph::Id, cranelift_egraph::EClass> as core::iter::traits::iterator::Iterator>::next <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::DynamicType, cranelift_codegen::ir::dynamic_type::DynamicTypeData> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 32 | 139k | fn next(&mut self) -> Option<Self::Item> { | 33 | 139k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) | 34 | 139k | } |
Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::GlobalValue, cranelift_codegen::ir::globalvalue::GlobalValueData> as core::iter::traits::iterator::Iterator>::next <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::DynamicStackSlot, cranelift_codegen::ir::stackslot::DynamicStackSlotData> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 32 | 139k | fn next(&mut self) -> Option<Self::Item> { | 33 | 139k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) | 34 | 139k | } |
<cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Heap, cranelift_codegen::ir::heap::HeapData> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 32 | 1.46M | fn next(&mut self) -> Option<Self::Item> { | 33 | 1.46M | self.enumerate.next().map(|(i, v)| (K::new(i), v)) | 34 | 1.46M | } |
<cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Block, cranelift_codegen::remove_constant_phis::BlockSummary> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 32 | 293k | fn next(&mut self) -> Option<Self::Item> { | 33 | 293k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) | 34 | 293k | } |
<cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Table, cranelift_codegen::ir::table::TableData> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 32 | 1.39M | fn next(&mut self) -> Option<Self::Item> { | 33 | 1.39M | self.enumerate.next().map(|(i, v)| (K::new(i), v)) | 34 | 1.39M | } |
Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::Value, cranelift_codegen::ir::dfg::ValueDataPacked> as core::iter::traits::iterator::Iterator>::next Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::SigRef, cranelift_codegen::ir::extfunc::Signature> as core::iter::traits::iterator::Iterator>::next Unexecuted instantiation: <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::FuncRef, cranelift_codegen::ir::extfunc::ExtFuncData> as core::iter::traits::iterator::Iterator>::next <cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::JumpTable, cranelift_codegen::ir::jumptable::JumpTableData> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 32 | 1.40M | fn next(&mut self) -> Option<Self::Item> { | 33 | 1.40M | self.enumerate.next().map(|(i, v)| (K::new(i), v)) | 34 | 1.40M | } |
<cranelift_entity::iter::Iter<cranelift_codegen::ir::entities::StackSlot, cranelift_codegen::ir::stackslot::StackSlotData> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 32 | 139k | fn next(&mut self) -> Option<Self::Item> { | 33 | 139k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) | 34 | 139k | } |
<cranelift_entity::iter::Iter<cranelift_codegen::machinst::vcode::VCodeConstant, cranelift_codegen::machinst::vcode::VCodeConstantData> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 32 | 176k | fn next(&mut self) -> Option<Self::Item> { | 33 | 176k | self.enumerate.next().map(|(i, v)| (K::new(i), v)) | 34 | 176k | } |
|
35 | | |
36 | | fn size_hint(&self) -> (usize, Option<usize>) { |
37 | | self.enumerate.size_hint() |
38 | | } |
39 | | } |
40 | | |
41 | | impl<'a, K: EntityRef, V> DoubleEndedIterator for Iter<'a, K, V> { |
42 | 0 | fn next_back(&mut self) -> Option<Self::Item> { |
43 | 0 | self.enumerate.next_back().map(|(i, v)| (K::new(i), v)) |
44 | 0 | } |
45 | | } |
46 | | |
47 | | impl<'a, K: EntityRef, V> ExactSizeIterator for Iter<'a, K, V> {} |
48 | | |
49 | | /// Iterate over all keys in order. |
50 | | pub struct IterMut<'a, K: EntityRef, V> |
51 | | where |
52 | | V: 'a, |
53 | | { |
54 | | enumerate: Enumerate<slice::IterMut<'a, V>>, |
55 | | unused: PhantomData<K>, |
56 | | } |
57 | | |
58 | | impl<'a, K: EntityRef, V> IterMut<'a, K, V> { |
59 | | /// Create an `IterMut` iterator that visits the `PrimaryMap` keys and values |
60 | | /// of `iter`. |
61 | | pub fn new(iter: slice::IterMut<'a, V>) -> Self { |
62 | | Self { |
63 | | enumerate: iter.enumerate(), |
64 | | unused: PhantomData, |
65 | | } |
66 | | } |
67 | | } |
68 | | |
69 | | impl<'a, K: EntityRef, V> Iterator for IterMut<'a, K, V> { |
70 | | type Item = (K, &'a mut V); |
71 | | |
72 | | fn next(&mut self) -> Option<Self::Item> { |
73 | | self.enumerate.next().map(|(i, v)| (K::new(i), v)) |
74 | | } |
75 | | |
76 | | fn size_hint(&self) -> (usize, Option<usize>) { |
77 | | self.enumerate.size_hint() |
78 | | } |
79 | | } |
80 | | |
81 | | impl<'a, K: EntityRef, V> DoubleEndedIterator for IterMut<'a, K, V> { |
82 | | fn next_back(&mut self) -> Option<Self::Item> { |
83 | | self.enumerate.next_back().map(|(i, v)| (K::new(i), v)) |
84 | | } |
85 | | } |
86 | | |
87 | | impl<'a, K: EntityRef, V> ExactSizeIterator for IterMut<'a, K, V> {} |
88 | | |
89 | | /// Iterate over all keys in order. |
90 | | pub struct IntoIter<K: EntityRef, V> { |
91 | | enumerate: Enumerate<vec::IntoIter<V>>, |
92 | | unused: PhantomData<K>, |
93 | | } |
94 | | |
95 | | impl<K: EntityRef, V> IntoIter<K, V> { |
96 | | /// Create an `IntoIter` iterator that visits the `PrimaryMap` keys and values |
97 | | /// of `iter`. |
98 | | pub fn new(iter: vec::IntoIter<V>) -> Self { |
99 | | Self { |
100 | | enumerate: iter.enumerate(), |
101 | | unused: PhantomData, |
102 | | } |
103 | | } |
104 | | } |
105 | | |
106 | | impl<K: EntityRef, V> Iterator for IntoIter<K, V> { |
107 | | type Item = (K, V); |
108 | | |
109 | | fn next(&mut self) -> Option<Self::Item> { |
110 | | self.enumerate.next().map(|(i, v)| (K::new(i), v)) |
111 | | } |
112 | | |
113 | | fn size_hint(&self) -> (usize, Option<usize>) { |
114 | | self.enumerate.size_hint() |
115 | | } |
116 | | } |
117 | | |
118 | | impl<K: EntityRef, V> DoubleEndedIterator for IntoIter<K, V> { |
119 | | fn next_back(&mut self) -> Option<Self::Item> { |
120 | | self.enumerate.next_back().map(|(i, v)| (K::new(i), v)) |
121 | | } |
122 | | } |
123 | | |
124 | | impl<K: EntityRef, V> ExactSizeIterator for IntoIter<K, V> {} |