Skip to content

Commit 8f5b674

Browse files
committed
ref parsing to not fork the input
1 parent ddae621 commit 8f5b674

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

relay-event-derive/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,16 @@ enum Size {
348348

349349
impl syn::parse::Parse for Size {
350350
fn parse(input: ParseStream) -> syn::Result<Self> {
351-
let head = input.fork();
352-
if let Ok(lit) = input.parse::<LitInt>() {
351+
if input.peek(LitInt) {
352+
let lit = input.parse::<LitInt>()?;
353353
return Ok(Self::Static(lit.base10_parse()?));
354354
}
355355

356-
let head_head = head.fork();
357-
let path = head.parse::<LitStr>()?;
358-
let path = path
356+
let head = input.fork();
357+
let path = input
358+
.parse::<LitStr>()?
359359
.parse()
360-
.map_err(|_| head_head.error("Expected a function name"))?;
360+
.map_err(|_| head.error("Expected a function name"))?;
361361
Ok(Self::Dynamic(path))
362362
}
363363
}

0 commit comments

Comments
 (0)