From e4318df495ce216147b7d5de89b2743bb563db28 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Tue, 20 Nov 2018 04:10:48 -0700 Subject: [PATCH] clippy stuff --- src/io_registers.rs | 11 ++++++----- src/lib.rs | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/io_registers.rs b/src/io_registers.rs index 3682f64..d97542c 100644 --- a/src/io_registers.rs +++ b/src/io_registers.rs @@ -34,7 +34,7 @@ newtype!( impl DisplayControlSetting { pub const BG_MODE_MASK: u16 = 0b111; - pub fn mode(&self) -> DisplayControlMode { + pub fn mode(self) -> DisplayControlMode { match self.0 & Self::BG_MODE_MASK { 0 => DisplayControlMode::Tiled0, 1 => DisplayControlMode::Tiled1, @@ -73,6 +73,7 @@ impl DisplayControlSetting { } /// The six display modes available on the GBA. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum DisplayControlMode { /// This basically allows for the most different things at once (all layers, /// 1024 tiles, two palette modes, etc), but you can't do affine @@ -415,7 +416,7 @@ newtype!(KeyInputSetting, u16, "A newtype over the key input state of the GBA"); #[allow(missing_docs)] impl KeyInputSetting { - register_bit!(A_BIT, u16, 1 << 0, a_pressed); + register_bit!(A_BIT, u16, 1, a_pressed); register_bit!(B_BIT, u16, 1 << 1, b_pressed); register_bit!(SELECT_BIT, u16, 1 << 2, select_pressed); register_bit!(START_BIT, u16, 1 << 3, start_pressed); @@ -427,13 +428,13 @@ impl KeyInputSetting { register_bit!(L_BIT, u16, 1 << 9, l_pressed); /// Takes the difference between these keys and another set of keys. - pub fn difference(&self, other: KeyInputSetting) -> KeyInputSetting { + pub fn difference(self, other: KeyInputSetting) -> KeyInputSetting { KeyInputSetting(self.0 ^ other.0) } /// Gives the arrow pad value as a tribool, with Plus being increased column /// value (right). - pub fn column_direction(&self) -> TriBool { + pub fn column_direction(self) -> TriBool { if self.right_pressed() { TriBool::Plus } else if self.left_pressed() { @@ -445,7 +446,7 @@ impl KeyInputSetting { /// Gives the arrow pad value as a tribool, with Plus being increased row /// value (down). - pub fn row_direction(&self) -> TriBool { + pub fn row_direction(self) -> TriBool { if self.down_pressed() { TriBool::Plus } else if self.up_pressed() { diff --git a/src/lib.rs b/src/lib.rs index 0bc4777..fc08aa5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), feature(asm))] #![warn(missing_docs)] +#![allow(clippy::cast_lossless)] //! This crate helps you write GBA ROMs. //!