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

Enable u2i by default

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Unknown
    • Resolution: Fixed
    • None
    • 2.0.0, bson-2.0.0
    • BSON
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: