diff --git a/emu/src/bitwise.rs b/emu/src/bitwise.rs index da2fa7b..92b2ca0 100644 --- a/emu/src/bitwise.rs +++ b/emu/src/bitwise.rs @@ -39,15 +39,6 @@ where *self = >::try_from(bitwise).unwrap(); } - /// Switches from 1 to 0, or conversely from 0 to 1 - fn toggle_bit(&mut self, bit_idx: u8) { - debug_assert!(bit_idx < (size_of::() * 8) as u8); - let mut bitwise: u128 = >::into(self.clone()); - let mask = 0b1 << bit_idx; - bitwise ^= mask; - *self = >::try_from(bitwise).unwrap(); - } - fn set_bit(&mut self, bit_idx: u8, value: bool) { match value { false => self.set_bit_off(bit_idx), @@ -163,7 +154,6 @@ impl Bits for u8 {} #[cfg(test)] mod tests { use super::*; - use rand::Rng; #[test] fn test_is_on() { @@ -207,17 +197,6 @@ mod tests { assert_eq!(b, 0b1100001100); } - #[test] - fn toggle_bit() { - let original = rand::thread_rng().gen_range(1..=u32::MAX - 1); - let mut fin = original; - for i in 0..32 { - fin.toggle_bit(i) - } - - assert_eq!(!original, fin); - } - #[test] fn set_bit() { let mut b = 0b1100110_u32; diff --git a/ui/src/gba_display.rs b/ui/src/gba_display.rs index 1bb1604..00b66cf 100644 --- a/ui/src/gba_display.rs +++ b/ui/src/gba_display.rs @@ -20,6 +20,7 @@ impl GbaDisplay { Self { gba } } + #[allow(clippy::needless_pass_by_ref_mut)] fn ui(&mut self, ui: &mut Ui) { //TODO: Fix this .lock().unwrap() repeated two times let rgb_data = self diff --git a/ui/src/savegame.rs b/ui/src/savegame.rs index 8278974..c1305b8 100644 --- a/ui/src/savegame.rs +++ b/ui/src/savegame.rs @@ -31,14 +31,17 @@ impl SaveGame { let cpu = &self.gba.lock().unwrap().cpu; let encoded = bincode::serialize(cpu)?; - let mut file = fs::OpenOptions::new().write(true).create(true).open(path)?; + let mut file = fs::OpenOptions::new() + .write(true) + .truncate(true) + .open(path)?; file.write_all(&encoded)?; Ok(()) } - fn load_state(&mut self) -> Result<(), Box> { + fn load_state(&self) -> Result<(), Box> { let path = FileDialog::new() .set_location("~") .add_filter("Clementine save file", &["clm"])