mongodm-rs icon indicating copy to clipboard operation
mongodm-rs copied to clipboard

field! macro can't deal with Enum.

Open shenqingyi9 opened this issue 2 years ago • 0 comments

#[derive(Serialize, Deserialize)]
struct Foo {
    e: E,
}

#[derive(Serialize, Deserialize)]
enum E {
    A(Foo1)
}

#[derive(Serialize, Deserialize)]
struct Foo1 {
    f: String,
}

let f = Foo {
    e: E::A(Foo1 {
        f: "field string".to_string(),
    }),
};
println!("{}", bson::to_document(&f).unwrap());

Here we get a result

{ "e": { "A": { "f": "field string" } } }

However, we can't build the path "e.A.f" with field! macro now.

shenqingyi9 avatar Apr 30 '23 05:04 shenqingyi9