Skip to content

v1.0.79

Compare
Choose a tag to compare
@dtolnay dtolnay released this 15 Sep 22:01
· 1326 commits to master since this release
v1.0.79
9956589
  • Add serde(other) variant attribute for deserializing any variant that is not one of the others (#1382)

    #[derive(Deserialize)]
    #[serde(tag = "variant")]
    enum MyEnum {
        A(ModelA),
        B(ModelB),
        #[serde(other)]
        Unknown,
    }

    In this internally tagged enum the MyEnum::Unknown variant would be produced if the "variant" tag in the input is neither "A" nor "B".

    This feature is currently limited to externally tagged and adjacently tagged enums in which the other variant is a unit variant.