pub fn to_document_with_options<T>(
    value: &T,
    options: SerializerOptions
) -> Result<Document>
where T: Serialize + ?Sized,
Expand description

Encode a T into a Document, configuring the underlying serializer with the provided options.

#[derive(Debug, Serialize)]
struct MyData {
    a: String,
}

let data = MyData { a: "ok".to_string() };
let options = SerializerOptions::builder().human_readable(false).build();
let doc = bson::to_document_with_options(&data, options)?;
assert_eq!(doc, doc! { "a": "ok" });