From 426890e8567e5c08f21ee9062c629b0a2a33b130 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 7 Oct 2023 20:26:10 +0100 Subject: [PATCH 1/4] Don't manually implement hash_one --- agb-hashmap/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/agb-hashmap/src/lib.rs b/agb-hashmap/src/lib.rs index a4d6cb08..6044c6cb 100644 --- a/agb-hashmap/src/lib.rs +++ b/agb-hashmap/src/lib.rs @@ -470,9 +470,7 @@ where K: Borrow, Q: Hash + ?Sized, { - let mut hasher = self.hasher.build_hasher(); - key.hash(&mut hasher); - let result = hasher.finish(); + let result = self.hasher.hash_one(key); // we want to allow truncation here since we're reducing 64 bits to 32 #[allow(clippy::cast_possible_truncation)] From 845e3d027ae7f66af1542cb9c27f97b35d75d04e Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 7 Oct 2023 20:27:36 +0100 Subject: [PATCH 2/4] Remove pointless import --- agb-hashmap/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agb-hashmap/src/lib.rs b/agb-hashmap/src/lib.rs index 6044c6cb..8de5370c 100644 --- a/agb-hashmap/src/lib.rs +++ b/agb-hashmap/src/lib.rs @@ -31,7 +31,7 @@ use core::{ alloc::Allocator, borrow::Borrow, fmt::Debug, - hash::{BuildHasher, BuildHasherDefault, Hash, Hasher}, + hash::{BuildHasher, BuildHasherDefault, Hash}, iter::FromIterator, num::Wrapping, ops::Index, From 7454563325b792a94e19d9badc17e60a396e3d26 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 7 Oct 2023 20:28:09 +0100 Subject: [PATCH 3/4] Tests must come at the end --- agb/src/interrupt.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/agb/src/interrupt.rs b/agb/src/interrupt.rs index 6cb8593d..c30c4b45 100644 --- a/agb/src/interrupt.rs +++ b/agb/src/interrupt.rs @@ -350,20 +350,6 @@ impl VBlank { } } -#[cfg(test)] -mod tests { - use super::*; - - #[test_case] - fn test_interrupt_table_length(_gba: &mut crate::Gba) { - assert_eq!( - unsafe { INTERRUPT_TABLE.len() }, - Interrupt::Gamepak as usize + 1, - "interrupt table should be able to store gamepak interrupt" - ); - } -} - #[must_use] /// The behaviour of this function is undefined in the sense that it will output /// some information in some way that can be interpreted in a way to give some @@ -384,3 +370,17 @@ pub fn profiler(timer: &mut crate::timer::Timer, period: u16) -> InterruptHandle }) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test_case] + fn test_interrupt_table_length(_gba: &mut crate::Gba) { + assert_eq!( + unsafe { INTERRUPT_TABLE.len() }, + Interrupt::Gamepak as usize + 1, + "interrupt table should be able to store gamepak interrupt" + ); + } +} From 534a357d85b08e9d31f3b1d843581e308e1e9605 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 7 Oct 2023 20:39:13 +0100 Subject: [PATCH 4/4] Add another missing import --- agb-hashmap/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agb-hashmap/src/lib.rs b/agb-hashmap/src/lib.rs index 8de5370c..c39d8458 100644 --- a/agb-hashmap/src/lib.rs +++ b/agb-hashmap/src/lib.rs @@ -947,7 +947,7 @@ impl core::ops::Add for HashType { #[cfg(test)] mod test { - use core::cell::RefCell; + use core::{cell::RefCell, hash::Hasher}; use alloc::vec::Vec;