diff --git a/typify-impl/src/lib.rs b/typify-impl/src/lib.rs index d4b12545..30674861 100644 --- a/typify-impl/src/lib.rs +++ b/typify-impl/src/lib.rs @@ -263,12 +263,34 @@ impl std::fmt::Display for MapType { } } +impl<'de> serde::Deserialize<'de> for MapType { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + let s = <&str>::deserialize(deserializer)?; + Ok(Self::new(s)) + } +} + +impl From for MapType { + fn from(s: String) -> Self { + Self::new(&s) + } +} + impl From<&str> for MapType { fn from(s: &str) -> Self { Self::new(s) } } +impl From for MapType { + fn from(t: syn::Type) -> Self { + Self(t) + } +} + /// Settings that alter type generation. #[derive(Default, Debug, Clone)] pub struct TypeSpaceSettings {