about summary refs log tree commit diff
path: root/compiler/rustc_index/src/vec.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_index/src/vec.rs')
-rw-r--r--compiler/rustc_index/src/vec.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs
index 88298150a79..b866c8b8433 100644
--- a/compiler/rustc_index/src/vec.rs
+++ b/compiler/rustc_index/src/vec.rs
@@ -208,6 +208,11 @@ impl<I: Idx, T> IndexVec<I, Option<T>> {
     pub fn remove(&mut self, index: I) -> Option<T> {
         self.get_mut(index)?.take()
     }
+
+    #[inline]
+    pub fn contains(&self, index: I) -> bool {
+        self.get(index).and_then(Option::as_ref).is_some()
+    }
 }
 
 impl<I: Idx, T: fmt::Debug> fmt::Debug for IndexVec<I, T> {