Skip to content

Commit

Permalink
feat: kamt: deprecate kamt for_each
Browse files Browse the repository at this point in the history
I was going to leave this and deprecate it later, but we're making other
braking changes anyways (to the error type).
  • Loading branch information
Stebalien committed Jan 25, 2024
1 parent 8d814b3 commit cde61d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions ipld/kamt/benches/kamt_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ fn for_each(c: &mut Criterion) {
c.bench_function("KAMT for_each function", |b| {
b.iter(|| {
let a = BKamt::load_with_config(&cid, &db, TEST_CONFIG).unwrap();
#[allow(deprecated)]
black_box(a).for_each(|_k, _v: &BenchData| Ok(())).unwrap();
})
});
Expand Down
1 change: 1 addition & 0 deletions ipld/kamt/src/kamt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ where
/// assert_eq!(total, 3);
/// ```
#[inline]
#[deprecated = "use `.iter()` instead"]
pub fn for_each<F>(&self, mut f: F) -> Result<(), Error>
where
V: DeserializeOwned,
Expand Down
3 changes: 3 additions & 0 deletions ipld/kamt/tests/kamt_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ fn for_each(factory: KamtFactory) {
// Iterating through kamt with dirty caches.
let mut sum = 0;
let expected_sum = 199 * 200 / 2;
#[allow(deprecated)]
kamt.for_each(|k, v| {
assert_eq!(*k as i32, *v);
sum += v;
Expand All @@ -154,6 +155,7 @@ fn for_each(factory: KamtFactory) {

// Iterating through kamt with no cache.
let mut sum = 0;
#[allow(deprecated)]
kamt.for_each(|_, v| {
sum += v;
Ok(())
Expand All @@ -163,6 +165,7 @@ fn for_each(factory: KamtFactory) {

// Iterating through kamt with cached nodes.
let mut sum = 0;
#[allow(deprecated)]
kamt.for_each(|_, v| {
sum += v;
Ok(())
Expand Down

0 comments on commit cde61d8

Please sign in to comment.