dtolnay / typetag

Serde serializable and deserializable trait objects
Apache License 2.0
1.19k stars 38 forks source link

Support untagged enum representation #12

Closed ghost closed 1 year ago

ghost commented 5 years ago

In addition to externally, internally, and adjacently tagged enum representations, serde also supports untagged representation.

It would be nice to have support for untagged representation in typetag too.

toxeus commented 3 years ago

IIUC serde's untagged enum representation basically bruteforces through all possible enum variants until one of them succeeds. To make this work with typetag a list of all types that implement a given trait would need to be collected. I don't know how hard that is. Perhaps @dtolnay has a better understanding on how involved implementing this would be?

dtolnay commented 1 year ago

I would prefer not to support this in this crate. But it would be reasonable for someone else to make a different crate implementing untagged enums.