From 79732df24cd44f8112b6b4583c0cf2c97dddc65d Mon Sep 17 00:00:00 2001 From: Tom Kaitchuck Date: Sat, 10 Feb 2024 15:52:54 -0800 Subject: [PATCH 1/2] Add test for key ref invariance Signed-off-by: Tom Kaitchuck --- tests/map_tests.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/map_tests.rs b/tests/map_tests.rs index 8d798a0..bdf37d8 100644 --- a/tests/map_tests.rs +++ b/tests/map_tests.rs @@ -200,6 +200,32 @@ fn test_ahash_alias_set_construction() { set.insert(1); } + +#[cfg(feature = "std")] +#[test] +fn test_key_ref() { + let mut map = ahash::HashMap::default(); + map.insert(1, "test"); + assert_eq!(Some((1, "test")), map.remove_entry(&1)); + + let mut map = ahash::HashMap::default(); + map.insert(&1, "test"); + assert_eq!(Some((&1, "test")), map.remove_entry(&&1)); + + let mut m = ahash::HashSet::>::default(); + m.insert(Box::from("hello".to_string())); + assert!(m.contains(&"hello".to_string())); + + let mut m = ahash::HashSet::::default(); + m.insert("hello".to_string()); + assert!(m.contains("hello")); + + let mut m = ahash::HashSet::>::default(); + m.insert(Box::from(&b"hello"[..])); + assert!(m.contains(&b"hello"[..])); +} + + fn ahash_vec(b: &Vec) -> u64 { let mut total: u64 = 0; for item in b { From 71f474247b653cdb96d9dfa64e7c31ed92a6b48b Mon Sep 17 00:00:00 2001 From: Jeffrey Vo Date: Sun, 11 Feb 2024 15:52:31 +1100 Subject: [PATCH 2/2] Bump rust-version to 1.72.0 (#196) * Bump rust-version to 1.72.0 * Bump rust version in MSRC CI check --- .github/workflows/rust.yml | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6907df1..327397e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -117,10 +117,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install 1.60.0 + - name: Install 1.72.0 uses: dtolnay/rust-toolchain@master with: - toolchain: 1.60.0 + toolchain: 1.72.0 - name: check run: cargo check no_std: diff --git a/Cargo.toml b/Cargo.toml index 7f2901f..2d65614 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" readme = "README.md" build = "./build.rs" exclude = ["/smhasher", "/benchmark_tools"] -rust-version = "1.60.0" +rust-version = "1.72.0" [lib] name = "ahash"