Skip to content

Commit

Permalink
Remove dependency on these
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoverton committed Mar 19, 2024
1 parent 6d3c42d commit eb29080
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 62 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion crates/mongodb-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ indexmap = { version = "1", features = ["serde"] } # must match the version that
schemars = "^0.8.12"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
these = "2.0.0"
thiserror = "1"

[dev-dependencies]
Expand Down
60 changes: 0 additions & 60 deletions crates/mongodb-support/src/align.rs
Original file line number Diff line number Diff line change
@@ -1,65 +1,5 @@
use indexmap::IndexMap;
use std::hash::Hash;
use these::These::{self, *};

pub fn align<K, T, U>(ts: IndexMap<K, T>, mut us: IndexMap<K, U>) -> IndexMap<K, These<T, U>>
where
K: Hash + Eq,
{
let mut result: IndexMap<K, These<T, U>> = IndexMap::new();

for (k, t) in ts {
match us.swap_remove(&k) {
None => result.insert(k, This(t)),
Some(u) => result.insert(k, Both(t, u)),
};
}

for (k, u) in us {
result.insert(k, That(u));
}
result
}

pub fn align_with<K, V, F>(ts: IndexMap<K, V>, mut us: IndexMap<K, V>, f: F) -> IndexMap<K, V>
where
K: Hash + Eq,
F: Fn(V, V) -> V,
{
let mut result: IndexMap<K, V> = IndexMap::new();

for (k, t) in ts {
match us.swap_remove(&k) {
None => result.insert(k, t),
Some(u) => result.insert(k, f(t, u)),
};
}

for (k, u) in us {
result.insert(k, u);
}
result
}

// pub fn align_with_result<K, V, E, F>(ts: IndexMap<K, V>, mut us: IndexMap<K, V>, f: F) -> Result<IndexMap<K, V>, E>
// where
// K: Hash + Eq,
// F: Fn(V, V) -> Result<V, E>,
// {
// let mut result: IndexMap<K, V> = IndexMap::new();

// for (k, t) in ts {
// match us.swap_remove(&k) {
// None => result.insert(k, t),
// Some(u) => result.insert(k, f(t, u)?),
// };
// }

// for (k, u) in us {
// result.insert(k, u);
// }
// Ok(result)
// }

pub fn align_with_result<K, T, U, V, E, FT, FU, FTU>(ts: IndexMap<K, T>, mut us: IndexMap<K, U>, ft: FT, fu: FU, ftu: FTU) -> Result<IndexMap<K, V>, E>
where
Expand Down

0 comments on commit eb29080

Please sign in to comment.