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
39
40
41
42
43
44
45
46
use syn::{
parse::{Parse, ParseStream, Result},
Expr, ExprClosure, LitStr, Token,
};
pub(crate) struct RexValArgs {
pub regex_str: LitStr,
pub value: Expr,
}
impl Parse for RexValArgs {
fn parse(input: ParseStream<'_>) -> Result<Self> {
let regex_str = input.parse::<LitStr>()?;
input.parse::<Token![,]>()?;
let value = input.parse::<Expr>()?;
let _ = input.parse::<Token![,]>();
Ok(RexValArgs { regex_str, value })
}
}
pub(crate) struct RexValFunArgs {
pub regex_str: LitStr,
pub value: Expr,
pub fun: ExprClosure,
}
impl Parse for RexValFunArgs {
fn parse(input: ParseStream<'_>) -> Result<Self> {
let regex_str = input.parse::<LitStr>()?;
input.parse::<Token![,]>()?;
let value = input.parse::<Expr>()?;
input.parse::<Token![,]>()?;
let fun = input.parse::<ExprClosure>()?;
let _ = input.parse::<Token![,]>();
Ok(RexValFunArgs {
regex_str,
value,
fun,
})
}
}