-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
Not Needed
-
NineLord has created PR #495: Impl Hash/Eq for BSON in bson-rust
Issue Text:
#494
Summery of changes:
- Added feature `hashable` to require the user to choose to opt-in using `Bson` as hash key.
Although, `serde_json` didn't bother with having this behind the feature flag, so If you like I can remove it. - `Bson::Double(f64)` - implemented the same solution as [`serde_json`](https://docs.rs/serde_json/1.0.127/src/serde_json/number.rs.html#53-70).
- `Bson::Document(Document)` - implemented the same solution as [`serde_json`](https://docs.rs/serde_json/1.0.127/src/serde_json/map.rs.html#395-397).
- `Bson::JavaScriptCodeWithScope(JavaScriptCodeWithScope)` - Able to impl Hash/Eq only if Document is impl Hash/Eq.
- `Bson::
{RegularExpression(Regex), Binary(Binary), Decimal128(Decimal128), DbPointer(DbPointer)}
` - Added Derive Hash/Eq without feature flag `hashable`, no reason for it not to implement those by default.
- Added unit test to show that using Bson as key works.
I didn't implement it yet, but if the above feature is acceptable,
it might be worth adding another feature like `not(preserve_order)` from `serde_json`,
to change `Bson::Document` to use `BTreeMap` instead of `indexmap` for more efficient hashing.
I don't mind adding this as a separate PR.