Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-2027

bson-rust - PR #495: Impl Hash/Eq for BSON

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • bson-2.12.0
    • Affects Version/s: None
    • Component/s: None
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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.

            Assignee:
            abraham.egnor@mongodb.com Abraham Egnor
            Reporter:
            tom.selander@mongodb.com Tom Selander
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: