From ebc4e15f3d9da4d944922eb6b67b6992f1930ca4 Mon Sep 17 00:00:00 2001 From: Corwin Date: Fri, 15 Jul 2022 21:59:36 +0100 Subject: [PATCH] constify sprite function --- agb/src/display/object.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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]