We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
IndexSet::get_index_of
1 parent c9235f3 commit eefb3beCopy full SHA for eefb3be
1 file changed
crates/wasmparser/src/collections/index_set.rs
@@ -81,6 +81,16 @@ where
81
self.inner.get_key_value(value).map(|(x, &())| x)
82
}
83
84
+ /// Return the index of the item provided, if it exists.
85
+ pub fn get_index_of<Q>(&self, value: &Q) -> Option<usize>
86
+ where
87
+ T: Borrow<Q>,
88
+ Q: Hash + Eq + Ord + ?Sized,
89
+ {
90
+ let (index, _, _) = self.inner.get_full(value)?;
91
+ Some(index)
92
+ }
93
+
94
/// Adds `value` to the [`IndexSet`].
95
///
96
/// Returns whether the value was newly inserted:
0 commit comments