From aa5676b1f2dc946bc359c1fd4081165814027caa Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 11 Jul 2020 10:30:26 -0400 Subject: [PATCH] Fix hub insertion --- wgpu-core/src/hub.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wgpu-core/src/hub.rs b/wgpu-core/src/hub.rs index 47ca13d6de..293db6bc97 100644 --- a/wgpu-core/src/hub.rs +++ b/wgpu-core/src/hub.rs @@ -138,8 +138,8 @@ impl Storage { pub fn insert(&mut self, id: I, value: T) { let (index, epoch, _) = id.unzip(); - if let Some(diff) = (index as usize).checked_sub(self.map.len()) { - self.map.resize_with(diff + 1, || Element::Vacant); + if index as usize >= self.map.len() { + self.map.resize_with(index as usize + 1, || Element::Vacant); } match std::mem::replace( &mut self.map[index as usize],