diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index 0b88c3e1..8f18f34b 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -249,8 +249,11 @@ impl Tag { } #[must_use] - pub fn sprite(&self, idx: usize) -> &'static Sprite { - &self.sprites()[idx] + pub const fn sprite(&self, idx: usize) -> &'static Sprite { + if idx >= self.len { + panic!("out of bounds access to sprite"); + } + unsafe { &*self.sprites.add(idx) } } #[inline]