/// A type-safe index for use with [IndexedSet]. Uses generational indices in debug builds to assert
/// A set that assigns a unique index to every entry. The returned index can be used to access the inserted entry.
if let Some(&existing) = self.index.find(hash, |&i| entry_matches(&self.table, i, &value)) {
if let Ok(entry) = self.index.find_entry(hash, |&i| entry_matches(&self.table, i, element)) {
fn entry_matches<T, Q: Equivalent<T> + ?Sized>(table: &[IndexSetEntry<T>], index: usize, value: &Q) -> bool {
fn entry_hash<T: Hash, S: BuildHasher>(table: &[IndexSetEntry<T>], hasher: &S, index: usize) -> u64 {