Remove const and rustfmt::skip

This commit is contained in:
Gwilym Kuiper 2022-08-11 20:52:35 +01:00
parent 31f85cf6b9
commit affea47a32

View file

@ -145,12 +145,19 @@ pub struct RegularMap {
pub const TRANSPARENT_TILE_INDEX: u16 = (1 << 10) - 1; pub const TRANSPARENT_TILE_INDEX: u16 = (1 << 10) - 1;
#[rustfmt::skip]
impl TiledMapPrivate for RegularMap { impl TiledMapPrivate for RegularMap {
fn tiles_mut(&mut self) -> &mut [Self::TileType] { &mut self.tiles } fn tiles_mut(&mut self) -> &mut [Self::TileType] {
fn tiles_dirty(&mut self) -> &mut bool { &mut self.tiles_dirty } &mut self.tiles
fn x_scroll_mut(&mut self) -> &mut Self::Position { &mut self.x_scroll } }
fn y_scroll_mut(&mut self) -> &mut Self::Position { &mut self.y_scroll } fn tiles_dirty(&mut self) -> &mut bool {
&mut self.tiles_dirty
}
fn x_scroll_mut(&mut self) -> &mut Self::Position {
&mut self.x_scroll
}
fn y_scroll_mut(&mut self) -> &mut Self::Position {
&mut self.y_scroll
}
} }
impl TiledMapTypes for RegularMap { impl TiledMapTypes for RegularMap {
@ -158,17 +165,28 @@ impl TiledMapTypes for RegularMap {
type Size = RegularBackgroundSize; type Size = RegularBackgroundSize;
} }
#[rustfmt::skip] impl TiledMapPrivateConst for RegularMap {
impl const TiledMapPrivateConst for RegularMap {
type TileType = Tile; type TileType = Tile;
type AffineMatrix = (); type AffineMatrix = ();
fn x_scroll(&self) -> Self::Position { self.x_scroll } fn x_scroll(&self) -> Self::Position {
fn y_scroll(&self) -> Self::Position { self.y_scroll } self.x_scroll
}
fn y_scroll(&self) -> Self::Position {
self.y_scroll
}
fn affine_matrix(&self) -> Self::AffineMatrix {} fn affine_matrix(&self) -> Self::AffineMatrix {}
fn background_id(&self) -> usize { self.background_id as usize } fn background_id(&self) -> usize {
fn screenblock(&self) -> usize { self.screenblock as usize } self.background_id as usize
fn priority(&self) -> Priority { self.priority } }
fn map_size(&self) -> Self::Size { self.size } fn screenblock(&self) -> usize {
self.screenblock as usize
}
fn priority(&self) -> Priority {
self.priority
}
fn map_size(&self) -> Self::Size {
self.size
}
fn bg_x(&self) -> MemoryMapped<Self::Position> { fn bg_x(&self) -> MemoryMapped<Self::Position> {
unsafe { MemoryMapped::new(0x0400_0010 + 4 * self.background_id as usize) } unsafe { MemoryMapped::new(0x0400_0010 + 4 * self.background_id as usize) }
} }
@ -247,12 +265,19 @@ pub struct AffineMap {
tiles_dirty: bool, tiles_dirty: bool,
} }
#[rustfmt::skip]
impl TiledMapPrivate for AffineMap { impl TiledMapPrivate for AffineMap {
fn tiles_mut(&mut self) -> &mut [Self::TileType] { &mut self.tiles } fn tiles_mut(&mut self) -> &mut [Self::TileType] {
fn tiles_dirty(&mut self) -> &mut bool { &mut self.tiles_dirty } &mut self.tiles
fn x_scroll_mut(&mut self) -> &mut Self::Position { &mut self.transform.position.x } }
fn y_scroll_mut(&mut self) -> &mut Self::Position { &mut self.transform.position.y } fn tiles_dirty(&mut self) -> &mut bool {
&mut self.tiles_dirty
}
fn x_scroll_mut(&mut self) -> &mut Self::Position {
&mut self.transform.position.x
}
fn y_scroll_mut(&mut self) -> &mut Self::Position {
&mut self.transform.position.y
}
} }
impl TiledMapTypes for AffineMap { impl TiledMapTypes for AffineMap {
@ -260,17 +285,30 @@ impl TiledMapTypes for AffineMap {
type Size = AffineBackgroundSize; type Size = AffineBackgroundSize;
} }
#[rustfmt::skip] impl TiledMapPrivateConst for AffineMap {
impl const TiledMapPrivateConst for AffineMap {
type TileType = u8; type TileType = u8;
type AffineMatrix = AffineMatrixAttributes; type AffineMatrix = AffineMatrixAttributes;
fn x_scroll(&self) -> Self::Position { self.transform.position.x } fn x_scroll(&self) -> Self::Position {
fn y_scroll(&self) -> Self::Position { self.transform.position.y } self.transform.position.x
fn affine_matrix(&self) -> Self::AffineMatrix { self.transform.matrix } }
fn background_id(&self) -> usize { self.background_id as usize } fn y_scroll(&self) -> Self::Position {
fn screenblock(&self) -> usize { self.screenblock as usize } self.transform.position.y
fn priority(&self) -> Priority { self.priority } }
fn map_size(&self) -> Self::Size { self.size } fn affine_matrix(&self) -> Self::AffineMatrix {
self.transform.matrix
}
fn background_id(&self) -> usize {
self.background_id as usize
}
fn screenblock(&self) -> usize {
self.screenblock as usize
}
fn priority(&self) -> Priority {
self.priority
}
fn map_size(&self) -> Self::Size {
self.size
}
fn bg_x(&self) -> MemoryMapped<Self::Position> { fn bg_x(&self) -> MemoryMapped<Self::Position> {
unsafe { MemoryMapped::new(0x0400_0008 + 0x10 * self.background_id()) } unsafe { MemoryMapped::new(0x0400_0008 + 0x10 * self.background_id()) }
} }