about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorhkalbasi <hamidrezakalbasi@protonmail.com>2023-02-26 16:04:41 +0330
committerhkalbasi <hamidrezakalbasi@protonmail.com>2023-03-06 21:09:09 +0330
commitac04bfd7a7223cc7077f6745c35f8b655ea13c73 (patch)
treefb993abefdda7f7673b7b715199119335eea4e1e /lib
parenta25710b0c01cc523b0f3732ca68321ac107a0ebe (diff)
downloadrust-ac04bfd7a7223cc7077f6745c35f8b655ea13c73.tar.gz
rust-ac04bfd7a7223cc7077f6745c35f8b655ea13c73.zip
Add `View Mir` command and fix some bugs
Diffstat (limited to 'lib')
-rw-r--r--lib/la-arena/src/map.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/la-arena/src/map.rs b/lib/la-arena/src/map.rs
index b9d491da3c0..7fff2b09c97 100644
--- a/lib/la-arena/src/map.rs
+++ b/lib/la-arena/src/map.rs
@@ -94,6 +94,12 @@ impl<T, V> ArenaMap<Idx<T>, V> {
             .filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_mut()?)))
     }
 
+    /// Returns an iterator over the arena indexes and values in the map.
+    // FIXME: Implement `IntoIterator` trait.
+    pub fn into_iter(self) -> impl Iterator<Item = (Idx<T>, V)> {
+        self.v.into_iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o?)))
+    }
+
     /// Gets the given key's corresponding entry in the map for in-place manipulation.
     pub fn entry(&mut self, idx: Idx<T>) -> Entry<'_, Idx<T>, V> {
         let idx = Self::to_idx(idx);