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

Enable u2i by default

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.0.0, bson-2.0.0
    • Affects Version/s: None
    • Component/s: BSON
    • Labels:
      None

      The u2i feature flag allows unsigned values to be serialized to BSON as signed integers if doing so could be done losslessly and error otherwise. This is gated behind a feature flag to prevent implicit casts. Perhaps we should reconsider whether the cost of implicit casts is worth the ergonomic benefits of being able to serialize unsigned integers without any special handling. Note that lossy casts are not a risk with u2i enabled, since serialization will just fail in the event of overflow. Also, we do already allow unsigned integers to be losslessly deserialized from signed ones.

      Note that in the BSON readme, we claim that "Any types that implement Serialize and Deserialize can be " mapped to/from BSON, though this isn't technically true unless the u2i feature flag is enabled.

            Assignee:
            patrick.freed@mongodb.com Patrick Freed
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: