aboutsummaryrefslogtreecommitdiff
path: root/macros/src/macro_flag.rs
blob: 257a059b9f61284eb88f93b950564982b869a0d9 (plain)
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
use syn::parse::{Parse, ParseStream};
use syn::{Ident, LitBool, Token};

#[derive(Debug)]
pub struct MacroFlag
{
    pub flag: Ident,
    pub is_on: LitBool,
}

impl Parse for MacroFlag
{
    fn parse(input: ParseStream) -> syn::Result<Self>
    {
        let input_forked = input.fork();

        let flag: Ident = input_forked.parse()?;

        input.parse::<Ident>()?;

        input.parse::<Token![=]>()?;

        let is_on: LitBool = input.parse()?;

        Ok(Self { flag, is_on })
    }
}