kardeiz / serde_tuple

MIT License
19 stars 6 forks source link

Enum support #13

Open UnlimitedCookies opened 1 month ago

UnlimitedCookies commented 1 month ago

Hi, it would be awesome to be able to also tuple serialize enum with fields in to json lists/tuples, where the first field is the name of the variant.

example:

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Action {
    Rule{pos: u16, rule_index: u16},
    Cut{start_index: u16, end_index: u16}
}

currently (de)serializes to {"rule":{"pos":0,"rule_index":0}} but I'd much rather have ["rule",0,0].

kardeiz commented 1 week ago

I think this would work and would probably be a good addition, if you would like to work on it! Currently this library only works with structs with named fields.