From 26244fbfbd6d55e10f52c8289a5bbbb892d2ebcf Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Thu, 10 Nov 2022 00:50:09 -0800 Subject: [PATCH] WIP. --- src/entity.rs | 2 ++ 1 file changed, 2 insertions(+) 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()); }