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
use syn::parse::{Parse, ParseStream, Result};
use syn::{Attribute, Generics, Ident, Token, Visibility, WhereClause};
pub struct UnitStruct {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
pub ident: Ident,
pub generics: Generics,
}
impl Parse for UnitStruct {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
let vis: Visibility = input.parse()?;
input.parse::<Token![struct]>()?;
let ident: Ident = input.parse()?;
input.fork().parse::<Token![<]>()?;
let generics: Generics = input.parse()?;
let where_clause: Option<WhereClause> = input.parse()?;
input.parse::<Token![;]>()?;
Ok(UnitStruct {
attrs: attrs,
vis: vis,
ident: ident,
generics: Generics {
where_clause: where_clause,
..generics
},
})
}
}