Map diff library, or snippet equivalent to Clojure's

Hi, I came from Clojure land, and am newbie in Rust.

In Clojure, comparing Map A to B can be done with
This function returns tuple of [things-only-in-a things-only-in-b things-in-both].
So for instance,

( {:a 1} {:a 1 :b 2})
will return:
=> (nil {:b 2} {:a 1})

I wonder if there's something similar in Rust.
In fact, does much more than map to map diff, but for now, I'm basically interested in map to map comparison.


I guess it only compares the keys, and not their values, right?

{BTree,Hash}Map don't have built-in methods for this, but {BTree,Hash}Set have difference, symmetric_difference, intersection, union, etc. I couldn't find a crate that does what you asked for (but I haven't looked thoroughly). Maybe you can write one?

It actually compares the values too.

( {:a 1 :c 1} {:a 1 :b 2 :c 3})
({:c 1} {:c 3, :b 2} {:a 1})

Thanks for checking. I was also doing some googling and couldn't find them, so I was thinking that might be the case.. I'll probably iterate through the key|value pair and generate diff that I need.