Improve panic report with reentrant SlotMap use (#22667)

`double_lease_panic` already does what we want, just extend it to the
indexing operation as well.

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-01-04 15:37:40 -05:00 committed by GitHub
parent 8151dc7696
commit de08e47e5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -117,8 +117,9 @@ impl EntityMap {
pub fn read<T: 'static>(&self, model: &Model<T>) -> &T { pub fn read<T: 'static>(&self, model: &Model<T>) -> &T {
self.assert_valid_context(model); self.assert_valid_context(model);
self.entities[model.entity_id] self.entities
.downcast_ref() .get(model.entity_id)
.and_then(|entity| entity.downcast_ref())
.unwrap_or_else(|| double_lease_panic::<T>("read")) .unwrap_or_else(|| double_lease_panic::<T>("read"))
} }