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

Implement From<Option<T>> for Bson where T: Into<Bson>

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • bson-2.0.0-beta.2
    • Affects Version/s: None
    • Component/s: BSON
    • None

      As an ergonomic improvement, we should implement From<Option<T>> for Bson for T that can be converted into Bson, returning Bson::Null in the None case.

      This would allow Option to more easily be used in the doc! macro:

      let x: Option<i32> = None;
      // current
      doc! { "x": x }; // compile error, Bson: From<Option<i32>> not satisfied
      
      // proposed
      doc! { "x": x }; // { "x": null }

       

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

              Created:
              Updated:
              Resolved: