From 408dc4e72ebdede00520b63634ae9dbd305e0503 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Tue, 14 Feb 2017 15:55:47 -0800 Subject: [PATCH] Add a contains_key method to SparseMap. --- lib/cretonne/src/sparse_map.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/cretonne/src/sparse_map.rs b/lib/cretonne/src/sparse_map.rs index 3a1b4dbdb6..ad49ac49fa 100644 --- a/lib/cretonne/src/sparse_map.rs +++ b/lib/cretonne/src/sparse_map.rs @@ -126,6 +126,11 @@ impl SparseMap None } + /// Return `true` if the map contains a value corresponding to `key`. + pub fn contains_key(&self, key: K) -> bool { + self.get(key).is_some() + } + /// Insert a value into the map. /// /// If the map did not have this key present, `None` is returned.