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

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Fixed
    • Priority: Minor - P4
    • bson-2.0.0-beta.2
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 (Inactive)
              Reporter:
              Patrick Freed
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: