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
33
34
35
36
37
38
use syn::{self, Field};
use Result;
pub trait FromField: Sized {
fn from_field(field: &Field) -> Result<Self>;
}
impl FromField for () {
fn from_field(_: &Field) -> Result<Self> {
Ok(())
}
}
impl FromField for Field {
fn from_field(field: &Field) -> Result<Self> {
Ok(field.clone())
}
}
impl FromField for syn::Type {
fn from_field(field: &Field) -> Result<Self> {
Ok(field.ty.clone())
}
}
impl FromField for syn::Visibility {
fn from_field(field: &Field) -> Result<Self> {
Ok(field.vis.clone())
}
}
impl FromField for Vec<syn::Attribute> {
fn from_field(field: &Field) -> Result<Self> {
Ok(field.attrs.clone())
}
}