From d22e46f7e36c01e2e1783c9aa156da7448188f6b Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Sun, 17 Oct 2021 22:08:33 +0100 Subject: [PATCH] resolve some clippy lints --- agb/src/agb_alloc/mod.rs | 8 ++++---- agb/src/bitarray.rs | 6 +++--- agb/src/lib.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/agb/src/agb_alloc/mod.rs b/agb/src/agb_alloc/mod.rs index edc8efc1..9e9408f4 100644 --- a/agb/src/agb_alloc/mod.rs +++ b/agb/src/agb_alloc/mod.rs @@ -39,7 +39,7 @@ mod test { let address = &*first_box as *const _ as usize; assert!( - address >= EWRAM_START && address < EWRAM_END, + (EWRAM_START..EWRAM_END).contains(&address), "ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {:#010X}", address ); @@ -53,8 +53,8 @@ mod test { v.push(i); } - for i in 0..100 { - assert_eq!(v[i], i); + for (i, &e) in v.iter().enumerate() { + assert_eq!(e, i); } } @@ -66,7 +66,7 @@ mod test { assert_eq!(*x, i); let address = &*x as *const _ as usize; assert!( - address >= EWRAM_START && address < EWRAM_END, + (EWRAM_START..EWRAM_END).contains(&address), "ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {:#010X}", address ); diff --git a/agb/src/bitarray.rs b/agb/src/bitarray.rs index 6f7c08ea..c237c36c 100644 --- a/agb/src/bitarray.rs +++ b/agb/src/bitarray.rs @@ -26,9 +26,9 @@ impl Bitarray { #[test_case] fn write_and_read(_gba: &mut crate::Gba) { let mut a: Bitarray<2> = Bitarray::new(); - assert_eq!(a.get(55).unwrap(), false, "expect unset values to be false"); + assert_eq!(a.get(55), Some(false), "expect unset values to be false"); a.set(62, true); - assert_eq!(a.get(62).unwrap(), true, "expect set value to be true"); + assert_eq!(a.get(62), Some(true), "expect set value to be true"); assert_eq!(a.get(120), None, "expect out of range to give None"); } @@ -38,7 +38,7 @@ fn test_everything(_gba: &mut crate::Gba) { let mut a: Bitarray<2> = Bitarray::new(); a.set(i, true); for j in 0..64 { - let expected = if i == j { true } else { false }; + let expected = i == j; assert_eq!( a.get(j).unwrap(), expected, diff --git a/agb/src/lib.rs b/agb/src/lib.rs index 8864b605..149ad46a 100644 --- a/agb/src/lib.rs +++ b/agb/src/lib.rs @@ -195,7 +195,7 @@ mod test { assert_eq!(content, 6, "expected data to have increased by one"); let address = ewram_ptr as usize; assert!( - address >= 0x0200_0000 && address < 0x0204_0000, + (0x0200_0000..0x0204_0000).contains(&address), "ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {:#010X}", address ); @@ -210,7 +210,7 @@ mod test { let iwram_ptr = &mut IWRAM_EXPLICIT as *mut u32; let address = iwram_ptr as usize; assert!( - address >= 0x0300_0000 && address < 0x0300_8000, + (0x0300_0000..0x0300_8000).contains(&address), "iwram is located beween 0x0300_0000 and 0x0300_8000, but was actually found to be at {:#010X}", address ); @@ -229,7 +229,7 @@ mod test { let iwram_ptr = &mut IMPLICIT_STORAGE as *mut u32; let address = iwram_ptr as usize; assert!( - address >= 0x0200_0000 && address < 0x0204_0000, + (0x0200_0000..0x0204_0000).contains(&address), "implicit data storage is expected to be in ewram, which is between 0x0300_0000 and 0x0300_8000, but was actually found to be at {:#010X}", address );