diff --git a/src/entity.rs b/src/entity.rs index 7678de0..43cf36c 100644 --- a/src/entity.rs +++ b/src/entity.rs @@ -148,12 +148,14 @@ pub struct PerEntity(Vec, Phantom impl Index for PerEntity { type Output = T; fn index(&self, idx: Idx) -> &T { + debug_assert!(idx.is_valid()); self.0.get(idx.index()).unwrap_or(&self.2) } } impl IndexMut for PerEntity { fn index_mut(&mut self, idx: Idx) -> &mut T { + debug_assert!(idx.is_valid()); if idx.index() >= self.0.len() { self.0.resize(idx.index() + 1, T::default()); }