darling_core/
from_type_param.rs

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