A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Implement `IntoIterator` for our OOM-handling `PrimaryMap` (#12605)
Nick Fitzgeralde581aa8b66b1
diff --git a/cranelift/entity/src/lib.rs b/cranelift/entity/src/lib.rsindex f412b277be..78dcd46095 100644--- a/cranelift/entity/src/lib.rs+++ b/cranelift/entity/src/lib.rs@@ -280,7 +280,7 @@ mod set;mod sparse;pub use self::boxed_slice::BoxedSlice;-pub use self::iter::{Iter, IterMut};+pub use self::iter::{IntoIter, Iter, IterMut};pub use self::keys::Keys;pub use self::list::{EntityList, ListPool};pub use self::map::SecondaryMap;diff --git a/crates/environ/src/collections/primary_map.rs b/crates/environ/src/collections/primary_map.rsindex 48137a1d10..e011c7d072 100644--- a/crates/environ/src/collections/primary_map.rs+++ b/crates/environ/src/collections/primary_map.rs@@ -255,3 +255,36 @@ where&mut self.inner[k]}}++impl<K, V> IntoIterator for PrimaryMap<K, V>+where+ K: EntityRef,+{+ type Item = (K, V);+ type IntoIter = cranelift_entity::IntoIter<K, V>;+ fn into_iter(self) -> Self::IntoIter {+ self.inner.into_iter()+ }+}++impl<'a, K, V> IntoIterator for &'a PrimaryMap<K, V>+where+ K: EntityRef,+{+ type Item = (K, &'a V);+ type IntoIter = cranelift_entity::Iter<'a, K, V>;+ fn into_iter(self) -> Self::IntoIter {+ self.iter()+ }+}++impl<'a, K, V> IntoIterator for &'a mut PrimaryMap<K, V>+where+ K: EntityRef,+{+ type Item = (K, &'a mut V);+ type IntoIter = cranelift_entity::IterMut<'a, K, V>;+ fn into_iter(self) -> Self::IntoIter {+ self.iter_mut()+ }+}