[−][src]Derive Macro activitystreams::UnitString
#[derive(UnitString)] { // Attributes available to this derive: #[unit_string] }
Derive implementations Serialize and Deserialize for a constant string Struct type
ⓘThis example is not tested
/// Derive Serialize and Deserialize such that MyStruct becomes the "MyType" string #[derive(Clone, Debug, UnitString)] #[unit_string(MyType)] pub struct MyStruct; // usage let _: HashMap<String, MyStruct> = serde_json::from_str(r#"{"type":"MyType"}"#)?;