Skip to content

Commit

Permalink
prefer collect into Vec
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminBrienen committed Dec 26, 2024
1 parent e71b195 commit e170e02
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ impl Parse for AllTuples {
pub fn all_tuples(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as AllTuples);
let len = 1 + input.end - input.start;
let mut ident_tuples = Vec::with_capacity(len);
for i in 0..=len {
let idents = input
.idents
.iter()
.map(|ident| format_ident!("{}{}", ident, i));
ident_tuples.push(to_ident_tuple(idents, input.idents.len()));
}

let ident_tuples = (0..=len)
.map(|i| {
let idents = input
.idents
.iter()
.map(|ident| format_ident!("{}{}", ident, i));
to_ident_tuple(idents, input.idents.len())
})
.collect::<Vec<_>>();
let macro_ident = &input.macro_ident;
let invocations = (input.start..=input.end).map(|i| {
let ident_tuples = choose_ident_tuples(&input, &ident_tuples, i);
Expand Down Expand Up @@ -238,15 +238,15 @@ pub fn all_tuples(input: TokenStream) -> TokenStream {
pub fn all_tuples_enumerated(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as AllTuples);
let len = 1 + input.end - input.start;
let mut ident_tuples = Vec::with_capacity(len);
for i in 0..=len {
let idents = input
.idents
.iter()
.map(|ident| format_ident!("{}{}", ident, i));
ident_tuples.push(to_ident_tuple_enumerated(idents, i));
}

let ident_tuples = (0..=len)
.map(|i| {
let idents = input
.idents
.iter()
.map(|ident| format_ident!("{}{}", ident, i));
to_ident_tuple_enumerated(idents, input.idents.len())
})
.collect::<Vec<_>>();
let macro_ident = &input.macro_ident;
let invocations = (input.start..=input.end).map(|i| {
let ident_tuples = choose_ident_tuples_enumerated(&input, &ident_tuples, i);
Expand Down Expand Up @@ -380,14 +380,15 @@ pub fn all_tuples_enumerated(input: TokenStream) -> TokenStream {
pub fn all_tuples_with_size(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as AllTuples);
let len = 1 + input.end - input.start;
let mut ident_tuples = Vec::with_capacity(len);
for i in 0..=len {
let idents = input
.idents
.iter()
.map(|ident| format_ident!("{}{}", ident, i));
ident_tuples.push(to_ident_tuple(idents, input.idents.len()));
}
let ident_tuples = (0..=len)
.map(|i| {
let idents = input
.idents
.iter()
.map(|ident| format_ident!("{}{}", ident, i));
to_ident_tuple(idents, input.idents.len())
})
.collect::<Vec<_>>();
let macro_ident = &input.macro_ident;
let invocations = (input.start..=input.end).map(|i| {
let ident_tuples = choose_ident_tuples(&input, &ident_tuples, i);
Expand Down

0 comments on commit e170e02

Please sign in to comment.