Lymia / enumset

A library for compact bit sets containing enums.
Apache License 2.0
91 stars 35 forks source link

Cannot use serde remote and serialize_as_list at the same time #16

Closed joonazan closed 4 years ago

joonazan commented 4 years ago
#[derive(EnumSetType, Serialize, Deserialize)]
#[enumset(serialize_as_list)]
#[serde(remote = "UnitType")]
pub enum UnitTypeDSL {
    Explorer,
    Town,
    City,
    Dahan,
}

This code doesn't compile, complaining that Serialize is not implemented.

joonazan commented 4 years ago

I don't actually need this because I found a better way to do what I wanted to do. I looked a bit into enumset_derive but I have no idea why those two are incompatible.

Lymia commented 4 years ago

Have you checked if serde actually implements Serialize on the type itself when you use #[serde(remote = ...)]? This is probably on serde's side, serialize_as_list requires the type itself implement Serialize and Deserialize, and that is about all.

joonazan commented 4 years ago

I'm sorry that I missed your earlier reply.

Serde remote deserializes the annotated type first and then converts it into the type named in remote. At least that is how I assume it works. All other deserialize modifiers that I've used do work on remote-annotated data structures.