Look up a key, returning an `Entry` that refers to an existing value or allows inserting a new one.
(&'a mut self, k: K, ctx: &Ctx)
| 118 | /// Look up a key, returning an `Entry` that refers to an existing |
| 119 | /// value or allows inserting a new one. |
| 120 | pub fn entry<'a, Ctx>(&'a mut self, k: K, ctx: &Ctx) -> Entry<'a, K, V> |
| 121 | where |
| 122 | Ctx: CtxEq<K, K> + CtxHash<K>, |
| 123 | { |
| 124 | let hash = compute_hash(ctx, &k); |
| 125 | let raw = self.raw.entry( |
| 126 | hash as u64, |
| 127 | |bucket| hash == bucket.hash && ctx.ctx_eq(&bucket.k, &k), |
| 128 | |bucket| compute_hash(ctx, &bucket.k) as u64, |
| 129 | ); |
| 130 | match raw { |
| 131 | hashbrown::hash_table::Entry::Occupied(o) => Entry::Occupied(OccupiedEntry { raw: o }), |
| 132 | hashbrown::hash_table::Entry::Vacant(v) => Entry::Vacant(VacantEntry { |
| 133 | hash, |
| 134 | key: k, |
| 135 | raw: v, |
| 136 | }), |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /// A reference to an existing or vacant entry in the hash table. |