fix: Properly parse Expressions, Idents, and Literals
This commit is contained in:
18
src/cmd.rs
18
src/cmd.rs
@@ -374,13 +374,17 @@ enum Value {
|
||||
|
||||
impl Parse for Value {
|
||||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
||||
if input.peek(syn::Lit) {
|
||||
input.parse().map(Self::Lit)
|
||||
} else if input.peek(syn::Ident) {
|
||||
input.parse().map(Self::Ident)
|
||||
} else {
|
||||
input.parse().map(Self::Expr)
|
||||
}
|
||||
let expr_fork = input.fork();
|
||||
expr_fork
|
||||
.parse::<syn::Expr>()
|
||||
.and_then(|_| input.parse().map(Self::Expr))
|
||||
.or_else(|_| {
|
||||
let ident_fork = input.fork();
|
||||
ident_fork
|
||||
.parse::<syn::Ident>()
|
||||
.and_then(|_| input.parse().map(Self::Ident))
|
||||
})
|
||||
.or_else(|_| input.parse().map(Self::Lit))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user