From 92066f7adbe5bd352b152be22884474bcdbb269f Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Thu, 23 Feb 2023 20:46:28 +0000 Subject: [PATCH] Add lifetimes to timers --- agb/src/save/mod.rs | 1 + agb/src/timer.rs | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/agb/src/save/mod.rs b/agb/src/save/mod.rs index b240efad..915f89ed 100644 --- a/agb/src/save/mod.rs +++ b/agb/src/save/mod.rs @@ -375,6 +375,7 @@ mod marker { /// Allows access to the cartridge's save data. #[non_exhaustive] pub struct SaveManager {} + impl SaveManager { pub(crate) const fn new() -> Self { SaveManager {} diff --git a/agb/src/timer.rs b/agb/src/timer.rs index 6b7c8906..307f5b64 100644 --- a/agb/src/timer.rs +++ b/agb/src/timer.rs @@ -1,3 +1,5 @@ +use core::marker::PhantomData; + use crate::memory_mapped::MemoryMapped; const fn timer_data(timer: usize) -> MemoryMapped { @@ -39,16 +41,20 @@ pub struct Timer { } #[non_exhaustive] -pub struct Timers { +pub struct Timers<'gba> { pub timer2: Timer, pub timer3: Timer, + + phantom: PhantomData<&'gba ()>, } -impl Timers { +impl Timers<'_> { pub(crate) unsafe fn new() -> Self { Self { timer2: Timer::new(2), timer3: Timer::new(3), + + phantom: PhantomData, } } } @@ -129,7 +135,7 @@ impl TimerController { Self {} } - pub fn timers(&mut self) -> Timers { + pub fn timers(&mut self) -> Timers<'_> { unsafe { Timers::new() } } }