summaryrefslogtreecommitdiffstats
path: root/src/tools/rust-analyzer/lib/la-arena
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/rust-analyzer/lib/la-arena')
-rw-r--r--src/tools/rust-analyzer/lib/la-arena/src/map.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/lib/la-arena/src/map.rs b/src/tools/rust-analyzer/lib/la-arena/src/map.rs
index b9d491da3..7fff2b09c 100644
--- a/src/tools/rust-analyzer/lib/la-arena/src/map.rs
+++ b/src/tools/rust-analyzer/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);