Open ngoquang2708 opened 3 months ago
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.
Currently I can deserialize HashMap with key as an enum as example bellow:
But I cannot serialize a HashMap to a string:
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.