Improve panic report with reentrant SlotMap use (#22667)
Cole Miller
created
`double_lease_panic` already does what we want, just extend it to the
indexing operation as well.
Release Notes:
- N/A
Change summary
crates/gpui/src/app/entity_map.rs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Detailed changes
@@ -117,8 +117,9 @@ impl EntityMap {
pub fn read<T: 'static>(&self, model: &Model<T>) -> &T {
self.assert_valid_context(model);
- self.entities[model.entity_id]
- .downcast_ref()
+ self.entities
+ .get(model.entity_id)
+ .and_then(|entity| entity.downcast_ref())
.unwrap_or_else(|| double_lease_panic::<T>("read"))
}