From 43da87939dd508350a93676fe2240d9b334a8d76 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 8 Mar 2023 18:38:09 -0800 Subject: [PATCH] Simplify parsing of borrow="..." attributes --- serde_derive/src/internals/attr.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/serde_derive/src/internals/attr.rs b/serde_derive/src/internals/attr.rs index 473458de..9b2162da 100644 --- a/serde_derive/src/internals/attr.rs +++ b/serde_derive/src/internals/attr.rs @@ -5,7 +5,7 @@ use quote::ToTokens; use std::borrow::Cow; use std::collections::BTreeSet; use syn; -use syn::parse::{Parse, ParseStream}; +use syn::parse::ParseStream; use syn::punctuated::Punctuated; use syn::Ident; use syn::Meta::{List, NameValue, Path}; @@ -1662,15 +1662,9 @@ fn parse_lit_into_lifetimes( return Err(()); } - struct BorrowedLifetimes(Punctuated); - - impl Parse for BorrowedLifetimes { - fn parse(input: ParseStream) -> syn::Result { - Punctuated::parse_separated_nonempty(input).map(BorrowedLifetimes) - } - } - - if let Ok(BorrowedLifetimes(lifetimes)) = string.parse() { + if let Ok(lifetimes) = + string.parse_with(Punctuated::::parse_separated_nonempty) + { let mut set = BTreeSet::new(); for lifetime in lifetimes { if !set.insert(lifetime.clone()) {