1 use syn::{self, TypeParam}; 2 3 use Result; 4 5 /// Creates an instance by parsing an individual type_param and its attributes. 6 pub trait FromTypeParam: Sized { from_type_param(type_param: &TypeParam) -> Result<Self>7 fn from_type_param(type_param: &TypeParam) -> Result<Self>; 8 } 9 10 impl FromTypeParam for () { from_type_param(_: &TypeParam) -> Result<Self>11 fn from_type_param(_: &TypeParam) -> Result<Self> { 12 Ok(()) 13 } 14 } 15 16 impl FromTypeParam for TypeParam { from_type_param(type_param: &TypeParam) -> Result<Self>17 fn from_type_param(type_param: &TypeParam) -> Result<Self> { 18 Ok(type_param.clone()) 19 } 20 } 21 22 impl FromTypeParam for Vec<syn::Attribute> { from_type_param(type_param: &TypeParam) -> Result<Self>23 fn from_type_param(type_param: &TypeParam) -> Result<Self> { 24 Ok(type_param.attrs.clone()) 25 } 26 } 27 28 impl FromTypeParam for syn::Ident { from_type_param(type_param: &TypeParam) -> Result<Self>29 fn from_type_param(type_param: &TypeParam) -> Result<Self> { 30 Ok(type_param.ident.clone()) 31 } 32 } 33