Skip to content

Allow serialization of unit variant as string #43

@ngoquang2708

Description

@ngoquang2708

Currently I can deserialize HashMap with key as an enum as example bellow:

#[derive(PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
enum Extension {
    #[serde(rename = "ut_metadata")]
    Metadata,
}
serde_bencode::from_str::<std::collections::HashMap<Extension, u8>>("d11:ut_metadatai1ee").unwrap();

But I cannot serialize a HashMap to a string:

serde_bencode::to_string(&std::collections::HashMap::from([(Extension::Metadata, 1)])).unwrap();

If I modifiy the serialize_newtype_struct() to allow serialize unit variant as a string the above code work. I don't know if it will break anything else so please consider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions