api-macros: Refactor unique_lifetimes_to_tokens

This commit is contained in:
Jonas Platte 2021-07-07 16:14:41 +02:00
parent fff4e97035
commit a59c43321f
No known key found for this signature in database
GPG Key ID: 7D261D771D915378

View File

@ -12,12 +12,11 @@ pub(crate) fn unique_lifetimes_to_tokens<'a, I: IntoIterator<Item = &'a Lifetime
lifetimes: I,
) -> TokenStream {
let lifetimes = lifetimes.into_iter().collect::<BTreeSet<_>>();
(!lifetimes.is_empty())
.then(|| {
let lifetimes = quote! { #( #lifetimes ),* };
quote! { < #lifetimes > }
})
.unwrap_or_default()
if lifetimes.is_empty() {
TokenStream::new()
} else {
quote! { < #( #lifetimes ),* > }
}
}
pub(crate) fn is_valid_endpoint_path(string: &str) -> bool {