Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[profile.default-miri]
# proptests are too slow to be run through miri
default-filter = "not test(proptest)"
default-filter = "not test(proptest) and not binary_id(iddqd::ui)"
38 changes: 35 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
# 1.85 is the MSRV
rust-version: ["1.85", "stable"]
rust-version: ["stable"]
partition: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
fail-fast: false
env:
Expand All @@ -72,7 +71,40 @@ jobs:
run: just powerset --partition ${{ matrix.partition }}/10 nextest run
- name: Doctests
run: just powerset --partition ${{ matrix.partition }}/10 test --doc


build-and-test-msrv:
name: Build and test (MSRV)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
# 1.85 is the MSRV
rust-version: ["1.85"]
partition: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
fail-fast: false
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
with:
key: partition-${{ matrix.partition }}-msrv
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@just
- uses: taiki-e/install-action@nextest
- name: Build
run: just powerset --partition ${{ matrix.partition }}/10 build
# We don't run UI tests on the MSRV since compiler output varies by
# version.
- name: Run tests (excluding UI tests)
run: just powerset --partition ${{ matrix.partition }}/10 nextest run -E 'not binary_id(iddqd::ui)'
- name: Doctests
run: just powerset --partition ${{ matrix.partition }}/10 test --doc


build-no-std:
name: Build on no-std
runs-on: ${{ matrix.os }}
Expand Down
121 changes: 114 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ serde = "1.0.223"
serde_core = "1.0.223"
serde_json = "1.0.145"
test-strategy = "0.4.3"
trybuild = "1.0.116"
typify = "0.4.2"

[profile.dev]
Expand Down
1 change: 1 addition & 0 deletions crates/iddqd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ iddqd-test-utils.workspace = true
proptest.workspace = true
serde.workspace = true
test-strategy.workspace = true
trybuild.workspace = true

[features]
allocator-api2 = ["iddqd-test-utils/allocator-api2"]
Expand Down
2 changes: 1 addition & 1 deletion crates/iddqd/src/bi_hash_map/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,7 @@ impl<T: BiHashItem, S: Clone + BuildHasher, A: Allocator> BiHashMap<T, S, A> {
/// ```
pub fn retain<'a, F>(&'a mut self, mut f: F)
where
F: FnMut(RefMut<'a, T, S>) -> bool,
F: for<'b> FnMut(RefMut<'b, T, S>) -> bool,
{
let hash_state = self.tables.state.clone();
let (_, mut dormant_items) = DormantMutRef::new(&mut self.items);
Expand Down
2 changes: 1 addition & 1 deletion crates/iddqd/src/id_hash_map/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ impl<T: IdHashItem, S: Clone + BuildHasher, A: Allocator> IdHashMap<T, S, A> {
/// ```
pub fn retain<'a, F>(&'a mut self, mut f: F)
where
F: FnMut(RefMut<'a, T, S>) -> bool,
F: for<'b> FnMut(RefMut<'b, T, S>) -> bool,
{
let hash_state = self.tables.state.clone();
let (_, mut dormant_items) = DormantMutRef::new(&mut self.items);
Expand Down
2 changes: 1 addition & 1 deletion crates/iddqd/src/id_ord_map/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ impl<T: IdOrdItem> IdOrdMap<T> {
/// ```
pub fn retain<'a, F>(&'a mut self, mut f: F)
where
F: FnMut(RefMut<'a, T>) -> bool,
F: for<'b> FnMut(RefMut<'b, T>) -> bool,
T::Key<'a>: Hash,
{
let hash_state = self.tables.state().clone();
Expand Down
2 changes: 1 addition & 1 deletion crates/iddqd/src/tri_hash_map/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2584,7 +2584,7 @@ impl<T: TriHashItem, S: Clone + BuildHasher, A: Allocator> TriHashMap<T, S, A> {
/// ```
pub fn retain<'a, F>(&'a mut self, mut f: F)
where
F: FnMut(RefMut<'a, T, S>) -> bool,
F: for<'b> FnMut(RefMut<'b, T, S>) -> bool,
{
let hash_state = self.tables.state.clone();
let (_, mut dormant_items) = DormantMutRef::new(&mut self.items);
Expand Down
35 changes: 34 additions & 1 deletion crates/iddqd/tests/integration/bi_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use iddqd_test_utils::{
},
};
use proptest::prelude::*;
use std::{borrow::Cow, path::Path};
use std::{
borrow::Cow,
path::{Path, PathBuf},
};
use test_strategy::{Arbitrary, proptest};

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -910,6 +913,36 @@ fn borrowed_item() {
}
}

#[test]
fn borrowed_item_retain_non_static() {
let foo_key = String::from("foo");
let bar_key = String::from("bar");
let foo_bytes = b"foo".to_vec();
let bar_bytes = b"bar".to_vec();
let foo_path = PathBuf::from("foo");
let bar_path = PathBuf::from("bar");

let mut map = BiHashMap::<BorrowedItem<'_>, HashBuilder, Alloc>::default();
map.insert_unique(BorrowedItem {
key1: foo_key.as_str(),
key2: Cow::Borrowed(foo_bytes.as_slice()),
key3: foo_path.as_path(),
})
.unwrap();
map.insert_unique(BorrowedItem {
key1: bar_key.as_str(),
key2: Cow::Borrowed(bar_bytes.as_slice()),
key3: bar_path.as_path(),
})
.unwrap();

map.retain(|item| item.key1 == foo_key.as_str());

assert_eq!(map.len(), 1);
assert!(map.get1(foo_key.as_str()).is_some());
assert!(map.get1(bar_key.as_str()).is_none());
}

#[test]
fn test_retain_all() {
let mut map = BiHashMap::<TestItem, HashBuilder, Alloc>::make_new();
Expand Down
Loading
Loading