1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use syn::TypeParam;

use crate::Result;

/// Creates an instance by parsing an individual type_param and its attributes.
pub trait FromTypeParam: Sized {
    fn from_type_param(type_param: &TypeParam) -> Result<Self>;
}

impl FromTypeParam for () {
    fn from_type_param(_: &TypeParam) -> Result<Self> {
        Ok(())
    }
}

impl FromTypeParam for TypeParam {
    fn from_type_param(type_param: &TypeParam) -> Result<Self> {
        Ok(type_param.clone())
    }
}

impl FromTypeParam for Vec<syn::Attribute> {
    fn from_type_param(type_param: &TypeParam) -> Result<Self> {
        Ok(type_param.attrs.clone())
    }
}

impl FromTypeParam for syn::Ident {
    fn from_type_param(type_param: &TypeParam) -> Result<Self> {
        Ok(type_param.ident.clone())
    }
}