Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
guerinoni committed Sep 26, 2024
1 parent 44bfb8b commit a7cc109
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
21 changes: 0 additions & 21 deletions emu/src/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ where
*self = <Self as TryFrom<u128>>::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::<Self>() * 8) as u8);
let mut bitwise: u128 = <Self as Into<u128>>::into(self.clone());
let mask = 0b1 << bit_idx;
bitwise ^= mask;
*self = <Self as TryFrom<u128>>::try_from(bitwise).unwrap();
}

fn set_bit(&mut self, bit_idx: u8, value: bool) {
match value {
false => self.set_bit_off(bit_idx),
Expand Down Expand Up @@ -163,7 +154,6 @@ impl Bits for u8 {}
#[cfg(test)]
mod tests {
use super::*;
use rand::Rng;

#[test]
fn test_is_on() {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ui/src/gba_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions ui/src/savegame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Error>> {
fn load_state(&self) -> Result<(), Box<dyn Error>> {
let path = FileDialog::new()
.set_location("~")
.add_filter("Clementine save file", &["clm"])
Expand Down

0 comments on commit a7cc109

Please sign in to comment.