Skip to content

Commit 69113be

Browse files
committed
More macro cleverness (3) avoid inferrable arguments
1 parent 47307e7 commit 69113be

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/tuple_impl.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,13 @@ macro_rules! count_ident{
248248
() => {0};
249249
($i0:ident, $($i:ident,)*) => {1 + count_ident!($($i,)*)};
250250
}
251+
macro_rules! ignore_ident{
252+
($id:ident, $($t:tt)*) => {$($t)*};
253+
}
251254

252255
macro_rules! impl_tuple_collect {
253-
($($X:ident),* ; $($Y:ident),* ; $($Y_rev:ident),*) => (
254-
impl<A> TupleCollect for ($($X),*,) {
256+
($($Y:ident),* ; $($Y_rev:ident),*) => (
257+
impl<A> TupleCollect for ($(ignore_ident!($Y, A),)*) {
255258
type Item = A;
256259
type Buffer = [Option<A>; count_ident!($($Y,)*) - 1];
257260

@@ -317,22 +320,21 @@ macro_rules! impl_tuple_collect {
317320
// use itertools::Itertools;
318321
//
319322
// for i in 1..=12 {
320-
// println!("impl_tuple_collect!({ty}; {idents}; {rev_idents});",
321-
// ty=iter::repeat("A").take(i).join(", "),
323+
// println!("impl_tuple_collect!({idents}; {rev_idents});",
322324
// idents=('a'..='z').take(i).join(", "),
323325
// rev_idents=('a'..='z').take(i).collect_vec().into_iter().rev().join(", ")
324326
// );
325327
// }
326328
// It could probably be replaced by a bit more macro cleverness.
327-
impl_tuple_collect!(A; a; a);
328-
impl_tuple_collect!(A, A; a, b; b, a);
329-
impl_tuple_collect!(A, A, A; a, b, c; c, b, a);
330-
impl_tuple_collect!(A, A, A, A; a, b, c, d; d, c, b, a);
331-
impl_tuple_collect!(A, A, A, A, A; a, b, c, d, e; e, d, c, b, a);
332-
impl_tuple_collect!(A, A, A, A, A, A; a, b, c, d, e, f; f, e, d, c, b, a);
333-
impl_tuple_collect!(A, A, A, A, A, A, A; a, b, c, d, e, f, g; g, f, e, d, c, b, a);
334-
impl_tuple_collect!(A, A, A, A, A, A, A, A; a, b, c, d, e, f, g, h; h, g, f, e, d, c, b, a);
335-
impl_tuple_collect!(A, A, A, A, A, A, A, A, A; a, b, c, d, e, f, g, h, i; i, h, g, f, e, d, c, b, a);
336-
impl_tuple_collect!(A, A, A, A, A, A, A, A, A, A; a, b, c, d, e, f, g, h, i, j; j, i, h, g, f, e, d, c, b, a);
337-
impl_tuple_collect!(A, A, A, A, A, A, A, A, A, A, A; a, b, c, d, e, f, g, h, i, j, k; k, j, i, h, g, f, e, d, c, b, a);
338-
impl_tuple_collect!(A, A, A, A, A, A, A, A, A, A, A, A; a, b, c, d, e, f, g, h, i, j, k, l; l, k, j, i, h, g, f, e, d, c, b, a);
329+
impl_tuple_collect!(a; a);
330+
impl_tuple_collect!(a, b; b, a);
331+
impl_tuple_collect!(a, b, c; c, b, a);
332+
impl_tuple_collect!(a, b, c, d; d, c, b, a);
333+
impl_tuple_collect!(a, b, c, d, e; e, d, c, b, a);
334+
impl_tuple_collect!(a, b, c, d, e, f; f, e, d, c, b, a);
335+
impl_tuple_collect!(a, b, c, d, e, f, g; g, f, e, d, c, b, a);
336+
impl_tuple_collect!(a, b, c, d, e, f, g, h; h, g, f, e, d, c, b, a);
337+
impl_tuple_collect!(a, b, c, d, e, f, g, h, i; i, h, g, f, e, d, c, b, a);
338+
impl_tuple_collect!(a, b, c, d, e, f, g, h, i, j; j, i, h, g, f, e, d, c, b, a);
339+
impl_tuple_collect!(a, b, c, d, e, f, g, h, i, j, k; k, j, i, h, g, f, e, d, c, b, a);
340+
impl_tuple_collect!(a, b, c, d, e, f, g, h, i, j, k, l; l, k, j, i, h, g, f, e, d, c, b, a);

0 commit comments

Comments
 (0)