Add correct lifetimes to windows

This commit is contained in:
Gwilym Kuiper 2023-02-23 20:37:03 +00:00
parent 0eec7e366c
commit 9757f7ed54
2 changed files with 7 additions and 3 deletions

View file

@ -88,7 +88,7 @@ impl ObjectDistribution {
pub struct WindowDist;
impl WindowDist {
pub fn get(&mut self) -> Windows {
pub fn get(&mut self) -> Windows<'_> {
Windows::new()
}
}

View file

@ -1,5 +1,7 @@
#![deny(missing_docs)]
//! The window feature of the GBA.
use core::marker::PhantomData;
use crate::{fixnum::Rect, memory_mapped::MemoryMapped};
use super::{tiled::BackgroundID, DISPLAY_CONTROL, HEIGHT, WIDTH};
@ -7,10 +9,11 @@ use super::{tiled::BackgroundID, DISPLAY_CONTROL, HEIGHT, WIDTH};
/// The windows feature of the Game Boy Advance can selectively display
/// backgrounds or objects on the screen and can selectively enable and disable
/// effects. This gives out references and holds changes before they can be committed.
pub struct Windows {
pub struct Windows<'a> {
wins: [MovableWindow; 2],
out: Window,
obj: Window,
phantom: PhantomData<&'a ()>,
}
const REG_HORIZONTAL_BASE: *mut u16 = 0x0400_0040 as *mut _;
@ -26,12 +29,13 @@ pub enum WinIn {
Win1,
}
impl Windows {
impl<'a> Windows<'a> {
pub(crate) fn new() -> Self {
let s = Self {
wins: [MovableWindow::new(), MovableWindow::new()],
out: Window::new(),
obj: Window::new(),
phantom: PhantomData,
};
s.commit();
s