Enum serialize to TOML?

Hi guys!

I get an UnsupportedType error when serializing an Enum to TOML:

The enum looks like this:

#[derive(Copy, Clone, Debug, Serialize)]
pub enum TheEnum {
    Var1(usize),
    Var2(usize),
}

and it is in a struct:

#[derive(Clone, Copy, Debug, Serialize)]
pub struct Metadata {
    config: TheEnum,
}

and then, serializing:

use toml::Value;
let result = Value::try_from(#something of Metadata Type#)?;

And then it fails when it does the Value::try_from, because apparently the TOML format does not support enums with values.

What should I do to make the struct Metadata serialized into TOML?

Apparently, the TOML crate doesn't seem to support newtype variants in enums. I'm not sure if it is intentional; in fact it seems to me like a bug.

As a workaround, you can try adding a dummy field to the variants in order to transform them into tuple variants rather than newtype variants.