-
Type: New Feature
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: BSON
-
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.