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

Lossy integer conversions performed in From<_> impls for Bson

      The From<u32> implementation for Bson performs a simple cast to i32, which will overflow and return negative numbers for large u32 values. This is also true for the From<u64> implementation. We should fix the u32 one to convert to an i64 as necessary and perhaps remove the u64 one altogether, as we cannot guarantee it will convert losslessly.

      Acceptance Criteria

      • Fix the u32 by casting to i64 when needed.
      • Since there is no i128, we can't fix u64 in the same way, so we should remove it since it is data lossy.
      • Add in a try block for the u64 case.

      Open Questions

      • How do we handle the backport? Is panicking a sensible option? Is deprecation the right option? 
        • Could panic safely if we also add the dep warning. 

            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: