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
35 changes: 10 additions & 25 deletions crates/iddqd/src/bi_hash_map/daft_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

use super::{BiHashItem, BiHashMap};
use crate::{IdHashItem, id_hash_map, support::daft_utils::IdLeaf};
use core::{borrow::Borrow, fmt, hash::Hash};
use core::{fmt, hash::Hash};
use daft::Diffable;
use derive_where::derive_where;
use equivalent::Equivalent;
use ref_cast::RefCast;

impl<T: BiHashItem> Diffable for BiHashMap<T> {
Expand Down Expand Up @@ -130,19 +131,15 @@ impl<'daft, T: ?Sized + BiHashItem + Eq> Diff<'daft, T> {
/// Returns true if the item corresponding to `key1` is unchanged.
pub fn is_unchanged1<'a, Q>(&'a self, key1: &Q) -> bool
where
T::K1<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K1<'a>>,
{
self.common.get1(key1).is_some_and(|leaf| leaf.is_unchanged())
}

/// Returns true if the item corresponding to `key2` is unchanged.
pub fn is_unchanged2<'a, Q>(&'a self, key2: &Q) -> bool
where
T::K2<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K2<'a>>,
{
self.common.get2(key2).is_some_and(|leaf| leaf.is_unchanged())
}
Expand All @@ -151,9 +148,7 @@ impl<'daft, T: ?Sized + BiHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_unchanged1<'a, Q>(&'a self, key: &Q) -> Option<&'daft T>
where
T::K1<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K1<'a>>,
{
self.common
.get1(key)
Expand All @@ -164,9 +159,7 @@ impl<'daft, T: ?Sized + BiHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_unchanged2<'a, Q>(&'a self, key: &Q) -> Option<&'daft T>
where
T::K2<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K2<'a>>,
{
self.common
.get2(key)
Expand All @@ -183,19 +176,15 @@ impl<'daft, T: ?Sized + BiHashItem + Eq> Diff<'daft, T> {
/// Returns true if the value corresponding to `key1` is modified.
pub fn is_modified1<'a, Q>(&'a self, key1: &Q) -> bool
where
T::K1<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K1<'a>>,
{
self.common.get1(key1).is_some_and(|leaf| leaf.is_modified())
}

/// Returns true if the value corresponding to `key2` is modified.
pub fn is_modified2<'a, Q>(&'a self, key2: &Q) -> bool
where
T::K2<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K2<'a>>,
{
self.common.get2(key2).is_some_and(|leaf| leaf.is_modified())
}
Expand All @@ -204,9 +193,7 @@ impl<'daft, T: ?Sized + BiHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_modified1<'a, Q>(&'a self, key: &Q) -> Option<IdLeaf<&'daft T>>
where
T::K1<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K1<'a>>,
{
self.common
.get1(key)
Expand All @@ -217,9 +204,7 @@ impl<'daft, T: ?Sized + BiHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_modified2<'a, Q>(&'a self, key: &Q) -> Option<IdLeaf<&'daft T>>
where
T::K2<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K2<'a>>,
{
self.common
.get2(key)
Expand Down
19 changes: 6 additions & 13 deletions crates/iddqd/src/id_hash_map/daft_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

use super::{IdHashItem, IdHashMap};
use crate::support::daft_utils::IdLeaf;
use core::{borrow::Borrow, hash::Hash};
use core::hash::Hash;
use daft::Diffable;
use equivalent::Equivalent;

impl<T: IdHashItem> Diffable for IdHashMap<T> {
type Diff<'a>
Expand Down Expand Up @@ -65,9 +66,7 @@ impl<'daft, T: ?Sized + IdHashItem + Eq> Diff<'daft, T> {
/// Returns true if the item corresponding to the key is unchanged.
pub fn is_unchanged<'a, Q>(&'a self, key: &Q) -> bool
where
T::Key<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::Key<'a>>,
{
self.common.get(key).is_some_and(|leaf| leaf.is_unchanged())
}
Expand All @@ -76,9 +75,7 @@ impl<'daft, T: ?Sized + IdHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_unchanged<'a, Q>(&'a self, key: &Q) -> Option<&'daft T>
where
T::Key<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::Key<'a>>,
{
self.common
.get(key)
Expand All @@ -96,9 +93,7 @@ impl<'daft, T: ?Sized + IdHashItem + Eq> Diff<'daft, T> {
/// modified.
pub fn is_modified<'a, Q>(&'a self, key: &Q) -> bool
where
T::Key<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::Key<'a>>,
{
self.common.get(key).is_some_and(|leaf| leaf.is_modified())
}
Expand All @@ -107,9 +102,7 @@ impl<'daft, T: ?Sized + IdHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_modified<'a, Q>(&'a self, key: &Q) -> Option<IdLeaf<&'daft T>>
where
T::Key<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::Key<'a>>,
{
self.common
.get(key)
Expand Down
18 changes: 5 additions & 13 deletions crates/iddqd/src/id_ord_map/daft_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use super::{IdOrdItem, IdOrdMap};
use crate::support::daft_utils::IdLeaf;
use core::borrow::Borrow;
use daft::Diffable;
use equivalent::Comparable;

impl<T: IdOrdItem> Diffable for IdOrdMap<T> {
type Diff<'a>
Expand Down Expand Up @@ -65,9 +65,7 @@ impl<'daft, T: ?Sized + IdOrdItem + Eq> Diff<'daft, T> {
/// Returns true if the item corresponding to the key is unchanged.
pub fn is_unchanged<'a, Q>(&'a self, key: &Q) -> bool
where
T::Key<'a>: Borrow<Q>,
T: 'a,
Q: Ord + ?Sized,
Q: ?Sized + Ord + Comparable<T::Key<'a>>,
{
self.common.get(key).is_some_and(|leaf| leaf.is_unchanged())
}
Expand All @@ -76,9 +74,7 @@ impl<'daft, T: ?Sized + IdOrdItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_unchanged<'a, Q>(&'a self, key: &Q) -> Option<&'daft T>
where
T::Key<'a>: Borrow<Q>,
T: 'a,
Q: Ord + ?Sized,
Q: ?Sized + Ord + Comparable<T::Key<'a>>,
{
self.common
.get(key)
Expand All @@ -96,9 +92,7 @@ impl<'daft, T: ?Sized + IdOrdItem + Eq> Diff<'daft, T> {
/// modified.
pub fn is_modified<'a, Q>(&'a self, key: &Q) -> bool
where
T::Key<'a>: Borrow<Q>,
T: 'a,
Q: Ord + ?Sized,
Q: ?Sized + Ord + Comparable<T::Key<'a>>,
{
self.common.get(key).is_some_and(|leaf| leaf.is_modified())
}
Expand All @@ -107,9 +101,7 @@ impl<'daft, T: ?Sized + IdOrdItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_modified<'a, Q>(&'a self, key: &Q) -> Option<IdLeaf<&'daft T>>
where
T::Key<'a>: Borrow<Q>,
T: 'a,
Q: Ord + ?Sized,
Q: ?Sized + Ord + Comparable<T::Key<'a>>,
{
self.common
.get(key)
Expand Down
51 changes: 14 additions & 37 deletions crates/iddqd/src/tri_hash_map/daft_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

use super::{TriHashItem, TriHashMap};
use crate::{IdHashItem, id_hash_map, support::daft_utils::IdLeaf};
use core::{borrow::Borrow, fmt, hash::Hash};
use core::{fmt, hash::Hash};
use daft::Diffable;
use derive_where::derive_where;
use equivalent::Equivalent;
use ref_cast::RefCast;

impl<T: TriHashItem> Diffable for TriHashMap<T> {
Expand Down Expand Up @@ -150,29 +151,23 @@ impl<'daft, T: ?Sized + TriHashItem + Eq> Diff<'daft, T> {
/// Returns true if the item corresponding to `key1` is unchanged.
pub fn is_unchanged1<'a, Q>(&'a self, key1: &Q) -> bool
where
T::K1<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K1<'a>>,
{
self.common.get1(key1).is_some_and(|leaf| leaf.is_unchanged())
}

/// Returns true if the item corresponding to `key2` is unchanged.
pub fn is_unchanged2<'a, Q>(&'a self, key2: &Q) -> bool
where
T::K2<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K2<'a>>,
{
self.common.get2(key2).is_some_and(|leaf| leaf.is_unchanged())
}

/// Returns true if the item corresponding to `key3` is unchanged.
pub fn is_unchanged3<'a, Q>(&'a self, key3: &Q) -> bool
where
T::K3<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K3<'a>>,
{
self.common.get3(key3).is_some_and(|leaf| leaf.is_unchanged())
}
Expand All @@ -181,9 +176,7 @@ impl<'daft, T: ?Sized + TriHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_unchanged1<'a, Q>(&'a self, key: &Q) -> Option<&'daft T>
where
T::K1<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K1<'a>>,
{
self.common
.get1(key)
Expand All @@ -194,9 +187,7 @@ impl<'daft, T: ?Sized + TriHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_unchanged2<'a, Q>(&'a self, key: &Q) -> Option<&'daft T>
where
T::K2<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K2<'a>>,
{
self.common
.get2(key)
Expand All @@ -207,9 +198,7 @@ impl<'daft, T: ?Sized + TriHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_unchanged3<'a, Q>(&'a self, key: &Q) -> Option<&'daft T>
where
T::K3<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K3<'a>>,
{
self.common
.get3(key)
Expand All @@ -226,29 +215,23 @@ impl<'daft, T: ?Sized + TriHashItem + Eq> Diff<'daft, T> {
/// Returns true if the value corresponding to `key1` is modified.
pub fn is_modified1<'a, Q>(&'a self, key1: &Q) -> bool
where
T::K1<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K1<'a>>,
{
self.common.get1(key1).is_some_and(|leaf| leaf.is_modified())
}

/// Returns true if the value corresponding to `key2` is modified.
pub fn is_modified2<'a, Q>(&'a self, key2: &Q) -> bool
where
T::K2<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K2<'a>>,
{
self.common.get2(key2).is_some_and(|leaf| leaf.is_modified())
}

/// Returns true if the value corresponding to `key3` is modified.
pub fn is_modified3<'a, Q>(&'a self, key3: &Q) -> bool
where
T::K3<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K3<'a>>,
{
self.common.get3(key3).is_some_and(|leaf| leaf.is_modified())
}
Expand All @@ -257,9 +240,7 @@ impl<'daft, T: ?Sized + TriHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_modified1<'a, Q>(&'a self, key: &Q) -> Option<IdLeaf<&'daft T>>
where
T::K1<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K1<'a>>,
{
self.common
.get1(key)
Expand All @@ -270,9 +251,7 @@ impl<'daft, T: ?Sized + TriHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_modified2<'a, Q>(&'a self, key: &Q) -> Option<IdLeaf<&'daft T>>
where
T::K2<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K2<'a>>,
{
self.common
.get2(key)
Expand All @@ -283,9 +262,7 @@ impl<'daft, T: ?Sized + TriHashItem + Eq> Diff<'daft, T> {
/// otherwise `None`.
pub fn get_modified3<'a, Q>(&'a self, key: &Q) -> Option<IdLeaf<&'daft T>>
where
T::K3<'a>: Borrow<Q>,
T: 'a,
Q: Hash + Eq + ?Sized,
Q: ?Sized + Hash + Equivalent<T::K3<'a>>,
{
self.common
.get3(key)
Expand Down