Helper function to manage interning of results to avoid duplicate initializers being inserted into the final list. `key` - the key being referenced which is used to deduplicate. `map` - a closure to access the interning map on `Self` `gen` - a closure to generate an intermediate value with `Self` from `K`. This is only used if `key` hasn't previously been seen. This closure can recursively intern
(
&mut self,
key: K,
map: impl Fn(&mut Self) -> &mut HashMap<K, V>,
generate: impl FnOnce(&mut Self, K) -> T,
init: impl FnOnce(V, T) -> GlobalInitializer,
| 1265 | /// initializers on-demand and avoid pushing more than one initializer at a |
| 1266 | /// time. |
| 1267 | fn intern<K, V, T>( |
| 1268 | &mut self, |
| 1269 | key: K, |
| 1270 | map: impl Fn(&mut Self) -> &mut HashMap<K, V>, |
| 1271 | generate: impl FnOnce(&mut Self, K) -> T, |
| 1272 | init: impl FnOnce(V, T) -> GlobalInitializer, |
| 1273 | ) -> V |
| 1274 | where |
| 1275 | K: Hash + Eq + Copy, |
| 1276 | V: EntityRef, |
| 1277 | { |
| 1278 | self.intern_(key, map, generate, |me, key, val| { |
| 1279 | me.initializers.push(init(key, val)); |
| 1280 | }) |
| 1281 | } |
| 1282 | |
| 1283 | fn intern_no_init<K, V, T>( |
| 1284 | &mut self, |
no test coverage detected