repetitive 0.3.1

Macro for generating repetitive code
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use syn::parse::ParseStream;

use super::*;

pub trait Peek {
    fn peek(input: ParseStream) -> bool;

    fn ctx_parse_option(input: ParseStream, ctx: &mut Context) -> Result<Option<Self>, Error>
    where
        Self: Sized + ContextParse,
    {
        Ok(if Self::peek(input) {
            Some(Self::ctx_parse(input, ctx)?)
        } else {
            None
        })
    }
}