1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
//! Procedural macros to generalize inherent and trait implementations over tuples.
//!
/*!
* [Introduction](#introduction)
* [Differences from `impl_trait_for_tuples`](#differences-from-impl_trait_for_tuples)
* [Examples](#examples)
## Introduction
When it is a need to implement either a trait
or a generalized type for a combination of tuples,
Rust requires separate implementations to be provided for each tuple variety manually.
This crate provides a proc-macro [`fortuples!`] to write code templates similar to the [`quote!`](https://docs.rs/quote/latest/quote/) macro.
This macro will expand the provided code template for each tuple variety.
Also, an attribute macro [`#[auto_impl]`](macro@auto_impl) that implements a given trait
for tuple combinations in a completely automatic way.
_This crate is inspired by the [`impl_trait_for_tuples`](https://docs.rs/impl-trait-for-tuples/latest/impl_trait_for_tuples/)._
----
## Differences from `impl_trait_for_tuples`
##### You can write inherent implementations
```
# use fortuples::fortuples;
struct Vector<T>(T);
fortuples! {
#[tuples::member_type(f32)]
#[tuples::min_size(2)]
#[tuples::max_size(3)]
#[tuples::tuple_name(Coords)]
impl Vector<#Coords> {
fn length(&self) -> f32 {
let coords = &self.0;
(#(#coords * #coords)+*).sqrt()
}
}
}
```
----
##### You don't need to use a custom keyword `for_tuples!` inside the implementation body
Instead, the [`fortuples!`] macro follows the [`quote!`](https://docs.rs/quote/latest/quote/)-like syntax without extra tokens.
```
trait Trait {
type Ret;
type Arg;
fn test(arg: Self::Arg) -> Self::Ret;
}
```
###### impl_trait_for_tuples
```
# use impl_trait_for_tuples::impl_for_tuples;
# trait Trait {
# type Ret;
# type Arg;
#
# fn test(arg: Self::Arg) -> Self::Ret;
# }
#[impl_for_tuples(5)]
impl Trait for Tuple {
for_tuples!( type Ret = ( #( Tuple::Ret ),* ); );
for_tuples!( type Arg = ( #( Tuple::Arg ),* ); );
fn test(arg: Self::Arg) -> Self::Ret {
for_tuples!( ( #( Tuple::test(arg.Tuple) ),* ) )
}
}
```
###### fortuples
```
# use fortuples::fortuples;
# trait Trait {
# type Ret;
# type Arg;
#
# fn test(arg: Self::Arg) -> Self::Ret;
# }
fortuples! {
#[tuples::max_size(5)] // <-- optional, default = 16
impl Trait for #Tuple
where
#(#Member: Trait),*
{
type Ret = ( #(#Member::Ret),* );
type Arg = ( #(#Member::Arg),* );
fn test(arg: Self::Arg) -> Self::Ret {
( #(#Member::test(#arg)),* )
}
}
}
```
----
##### Separate attribute macro for full-automatic implementation
###### impl_trait_for_tuples
```
# use impl_trait_for_tuples::impl_for_tuples;
#[impl_for_tuples(5)]
trait Notify {
fn notify(&self);
}
```
###### fortuples::auto_impl
```
#[fortuples::auto_impl]
#[tuples::max_size(5)] // <-- optional, default = 16
trait Notify {
fn notify(&self);
}
```
----
## Examples
#### [`fortuples!`] proc-macro
Here is commented example of [`fortuples!`] usage.
You can also view the example [without comments](#fortuples-proc-macro-without-comments) to see how the macro could look in the wild.
You can find the example's macro expansion [here](#fortuples-proc-macro-expansion).
_See the [`fortuples!`] macro documentation to learn about the macro settings (like `#[tuples::min_size]`)._
```
# use fortuples::fortuples;
trait Trait {
type Ret;
type Arg;
type FixedType;
const VALUE: i32;
const LENGTH: usize;
fn test_assoc_fn(arg: Self::Arg) -> Self::Ret;
fn test_self_fn(&self) -> Result<(), ()>;
}
fortuples! {
# #[tuples::debug_expand(path = "doc/expand/fortuples.rs")]
#[tuples::min_size(1)]
// +----- ^^^^^^^^^^^
// | The `fortuples!` macro will generate implementations starting with the empty tuple.
// |
// | Due to the `min_size` setting,
// | the implementations will start from the `(Member0,)` tuple.
impl Trait for #Tuple
// +----------- ^^^^^
// | a meta-variable that will expand to
// | `(Member0,)`, `(Member0, Member1)`, and so on.
where
#(#Member: Trait<FixedType = i32>),*
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// | A repetition -- the code inside the `#(...),*`
// | will expand as many times as many elements are in the current #Tuple.
// |
// | Inside the i-th code fragment, the #Member meta-variable will be substituted
// | by the i-th member type of the current #Tuple.
{
// The `Ret` type will be a tuple consisting of the `Ret` types
// from the current #Tuple member types
type Ret = (#(#Member::Ret),*);
// The `Arg` type will be a tuple consisting of the `Arg` types
// from the current #Tuple member types
type Arg = (#(#Member::Arg),*);
// The `VALUE` will be a sum of all `VALUE`s of the #Tuple member types.
const VALUE: i32 = #(#Member::VALUE)+*;
// +------------------------------- ^
// | Note that a `+` sign separates the `VALUE`s.
const LENGTH: usize = #len(Tuple);
// +----------------- ^^^^^^^^^^^
// | This expands to the current #Tuple length.
type FixedType = i32;
fn test_assoc_fn(arg: Self::Arg) -> Self::Ret {
( #(#Member::test_assoc_fn(#arg)),* )
// +----------------------- ^^^
// | Any identifier after the `#` sign that is neither
// | #Tuple, #Member, nor #len(Tuple)
// | is interpreted as a tuple variable.
// |
// | So the above code will expand like this:
// | ```
// | (
// | Member0::test_assoc_fn(arg.0),
// | Member1::test_assoc_fn(arg.1),
// | ...
// | MemberN::test_assoc_fn(arg.N),
// | )
// | ```
// | where `N` equals `#len(Tuple)`
}
fn test_self_fn(&self) -> Result<(), ()> {
#(#self.test_self_fn()?;)*
// +-------------------- ^
// | Note that there is no separator here.
Ok(())
}
}
}
```
<details>
<summary>Show the example without comments</summary>
#### [`fortuples!`] proc-macro (without comments)
```
# use fortuples::fortuples;
trait Trait {
type Ret;
type Arg;
type FixedType;
const VALUE: i32;
const LENGTH: usize;
fn test_assoc_fn(arg: Self::Arg) -> Self::Ret;
fn test_self_fn(&self) -> Result<(), ()>;
}
fortuples! {
#[tuples::min_size(1)]
impl Trait for #Tuple
where
#(#Member: Trait<FixedType = i32>),*
{
type Ret = (#(#Member::Ret),*);
type Arg = (#(#Member::Arg),*);
const VALUE: i32 = #(#Member::VALUE)+*;
const LENGTH: usize = #len(Tuple);
type FixedType = i32;
fn test_assoc_fn(arg: Self::Arg) -> Self::Ret {
( #(#Member::test_assoc_fn(#arg)),* )
}
fn test_self_fn(&self) -> Result<(), ()> {
#(#self.test_self_fn()?;)*
Ok(())
}
}
}
```
</details>
*/
/*!
<details>
<summary>Show the macro expansion</summary>
#### [`fortuples!`] proc-macro expansion
```
# trait Trait {
# type Ret;
#
# type Arg;
#
# type FixedType;
#
# const VALUE: i32;
#
# const LENGTH: usize;
#
# fn test_assoc_fn(arg: Self::Arg) -> Self::Ret;
#
# fn test_self_fn(&self) -> Result<(), ()>;
# }
*/
//!```
//!
//!</details>
//!
//! ----
/*!
#### [`auto_impl`](macro@auto_impl) attribute
There is an option to implement a trait
in a completely automatic way using the [`auto_impl`](macro@auto_impl) attribute.
This attribute will automatically generate implementations of the given trait
for tuple combinations.
To view the example's macro expansion, click [here](#auto_impl-proc-macro-expansion).
_See the [`auto_impl`](macro@auto_impl) documentation to learn about the
attribute's settings and limitations._
```
#[fortuples::auto_impl]
# #[tuples::debug_expand(path = "doc/expand/auto_impl.rs")]
trait AutoImplTrait {
fn test(&self, a: i32, b: &f32);
}
```
*/
/*!
<details>
<summary>Show the macro expansion</summary>
#### [`auto_impl`](macro@auto_impl) proc-macro expansion
```
# trait AutoImplTrait {
# fn test(&self, a: i32, b: &f32);
# }
*/
//!```
//!</details>
use TokenStream;
use ;
use ;
/// A macro for manual generalization of inherent and trait implementations over tuples.
///
/// This documentation will provide the macro's syntax and settings details.
///
/// If you're looking for an example, please see one
/// [inside the crate documentation](index.html#fortuples-proc-macro).
///
/// * [Syntax](#syntax)
/// - [Meta-variables](#meta-variables)
/// - [Repetition](#repetition)
/// - [#Member repetition](#member-repetition)
/// - [#\<id\> repetition](#id-repetition)
/// - [Recursion](#recursion)
/// * [Settings](#settings)
/// - [min_size](#min_size)
/// - [max_size](#max_size)
/// - [tuple_name](#tuple_name)
/// - [member_name](#member_name)
/// - [member_type](#member_type)
/// - [refs_tuple](#refs_tuple)
/// - [Immutable refs](#immutable-refs)
/// - [Mutable refs](#mutable-refs)
/// - [debug_expand](#debug_expand)
///
/// ## Syntax
///
/// The general syntax looks like the following:
/// ```ignore
/// fortuples! {
/// |optional: fortuples! settings and other attributes|
///
/// |optional unsafe| impl |optional generics| |implementation body|
/// }
/// ```
///
/// The macro will expand the provided code several times for different tuple varieties --
/// `()`, `(Member0,)`, `(Member0, Member1)`, and so on.
///
/// #### Meta-variables
/// The macro provides several meta-variables which can be used inside the `|implementation body|`:
/// * `#Tuple` expands to the current tuple -- `()`, `(Member0,)`, `(Member0, Member1)`, ...
/// * `#len(Tuple)` expands to the current tuple's length:
///
/// | #Tuple | #len(Tuple) |
/// | -------------------- | ------------- |
/// | `()` | `0usize` |
/// | `(Member0,)` | `1usize` |
/// | `(Member0, Member1)` | `2usize` |
/// | ... | ... |
///
/// * `#Member` expands to the current tuple's member type. It can be used within a repetition only (see below).
/// * `#<id>` (where `<id>` is an arbitrary identifier)
/// expands the `id` as if it were a tuple variable.
/// It can be used within a repetition only (see below).
///
/// #### Repetition
/// Repetition is done using `#(...)*` or `#(...),*` (or `#(...)<separator>*` in general).
///
/// It expands the code within the parentheses as often as many elements are in the current tuple
/// separated by the `<separator>` if provided.
/// > _Note: when using a comma as a separator, the macro always leaves the trailing comma._
///
/// For instance, `#(println!("Hi");)*` will expand for different tuple varieties like the following:
///
/// | #Tuple | #(println!("Hi");)* |
/// | -------------------- | ---------------------------------------------------- |
/// | `()` | |
/// | `(Member0,)` | `println!("Hi");` |
/// | `(Member0, Member1)` | `println!("Hi"); println!("Hi");` |
/// | ... | ... |
///
/// ----
///
/// ###### #Member repetition
///
/// The meta-variable `#Member` expands like the following:
///
/// | #Tuple | #(#Member),* |
/// | -------------------- | ---------------------------------------------------- |
/// | `()` | |
/// | `(Member0,)` | `Member0,` |
/// | `(Member0, Member1)` | `Member0, Member1,` |
/// | ... | ... |
///
/// ----
///
/// ###### #\<id\> repetition
///
/// The meta-variable `#<id>` expands like the following:
///
///
/// | #Tuple | #(#\<id\>),* |
/// | -------------------- | ---------------------------------------------------- |
/// | `()` | |
/// | `(Member0,)` | `<id>.0,` |
/// | `(Member0, Member1)` | `<id>.0, <id>.1,` |
/// | ... | ... |
///
/// ###### Recursion
/// You can do a repetition recursively:
///
/// | #Tuple | vec![ #(vec![ #(#myvar),\* ]),\* ] |
/// | -------------------- | ---------------------------------------------------------- |
/// | `()` | |
/// | `(Member0,)` | `vec![vec![myvar.0,],]` |
/// | `(Member0, Member1)` | `vec![vec![myvar.0, myvar.1,], vec![myvar.0, myvar.1,],]` |
/// | ... | ... |
///
/// ## Settings
///
/// #### min_size
/// `#[tuples::min_size]` sets the length of the first tuple. By default, it equals `0`.
///
/// ```
/// # use fortuples::fortuples;
/// trait Trait {}
///
/// fortuples! {
/// # #[tuples::debug_expand(path = "doc/expand/fortuples_min_size.rs")]
/// #[tuples::min_size(2)]
/// impl Trait for #Tuple {}
/// }
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>
///
/// #### max_size
/// `#[tuples::max_size]` sets the length of the last tuple. By default, it equals `16`.
///
/// ```
/// # use fortuples::fortuples;
/// trait Trait {}
///
/// fortuples! {
/// # #[tuples::debug_expand(path = "doc/expand/fortuples_max_size.rs")]
/// #[tuples::max_size(4)]
/// impl Trait for #Tuple {}
/// }
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>
///
/// #### tuple_name
/// `#[tuples::tuple_name]` sets the name of the meta-variable that represents the current tuple.
///
/// It is `Tuple` by default.
///
/// ```
/// # use fortuples::fortuples;
/// struct Vector<T>(T);
///
/// fortuples! {
/// # #[tuples::debug_expand(path = "doc/expand/tuple_name.rs")]
/// #[tuples::tuple_name(Coords)]
/// #[tuples::min_size(2)]
/// #[tuples::max_size(3)]
/// impl Vector<#Coords> {}
/// }
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # struct Vector<T>(T);
/// ```
///
/// </details>
///
/// #### member_name
/// `#[tuples::member_name]` sets the name of the meta-variable that represents
/// the current tuple's member type.
///
/// It is `Member` by default.
///
/// ```
/// # use fortuples::fortuples;
/// struct Vector<T>(T);
///
/// fortuples! {
/// # #[tuples::debug_expand(path = "doc/expand/member_name.rs")]
/// #[tuples::tuple_name(Coords)]
/// #[tuples::member_name(CoordT)]
/// #[tuples::min_size(2)]
/// #[tuples::max_size(3)]
/// impl Vector<#Coords>
/// where
/// #(#CoordT: Into<f32>),*
/// {}
/// }
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # struct Vector<T>(T);
/// ```
///
/// </details>
///
/// #### member_type
/// `#[tuples::member_type]` sets all member types to a specific type.
///
/// ```
/// # use fortuples::fortuples;
/// struct Vector<T>(T);
///
/// fortuples! {
/// # #[tuples::debug_expand(path = "doc/expand/member_type.rs")]
/// #[tuples::tuple_name(Coords)]
/// #[tuples::member_type(f32)]
/// #[tuples::min_size(2)]
/// #[tuples::max_size(3)]
/// impl Vector<#Coords> {}
/// }
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # struct Vector<T>(T);
/// ```
///
/// </details>
///
/// #### refs_tuple
/// `#[tuples::refs_tuple]` adds references to each member type inside the current tuple.
///
/// ###### Immutable refs
///
/// ```
/// # use fortuples::fortuples;
/// trait Trait {}
///
/// fortuples! {
/// # #[tuples::debug_expand(path = "doc/expand/fortuples_refs_tuple.rs")]
/// #[tuples::refs_tuple]
/// impl Trait for #Tuple {}
/// }
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>
///
/// ###### Mutable refs
///
/// ```
/// # use fortuples::fortuples;
/// trait Trait {}
///
/// fortuples! {
/// # #[tuples::debug_expand(path = "doc/expand/fortuples_refs_tuple_mut.rs")]
/// #[tuples::refs_tuple(mut)]
/// impl Trait for #Tuple {}
/// }
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>
///
/// #### debug_expand
///
/// `#[tuples::debug_expand]` will print the macro expansion.
///
/// The expansion can be printed either to stdout or a file.
/// * `#[tuples::debug_expand]` prints to stdout.
/// * `#[tuples::debug_expand(path = "<filepath>")]` prints to the file specified by the `<filepath>`.
///
/// All the macro expansions provided in this documentation were obtained using this setting.
///
/// >_Note: the `#[tuples::debug_expand]` prints the macro expansion only if the `debug` feature is enabled._
///
/// ```
/// # use fortuples::fortuples;
/// trait Trait {}
///
/// fortuples! {
/// #[tuples::debug_expand(path = "doc/expand/fortuples_debug_expand.rs")]
/// impl Trait for #Tuple {}
/// }
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>
/// An attribute macro for generating full-automatic trait implementations for tuples.
///
/// * [Syntax](#syntax)
/// * [Limitations](#limitations)
/// * [Settings](#settings)
/// - [min_size](#min_size)
/// - [max_size](#max_size)
/// - [refs_tuple](#refs_tuple)
/// - [Immutable refs](#immutable-refs)
/// - [Mutable refs](#mutable-refs)
/// - [debug_expand](#debug_expand)
///
/// ## Syntax
///
/// Just place the `#[fortuples::auto_impl]` attribute in front of a trait.
///
/// ```
/// #[fortuples::auto_impl]
/// # #[tuples::debug_expand(path = "doc/expand/auto_impl_syntax.rs")]
/// trait Trait {
/// fn no_args();
///
/// // Note that non-reference arguments should implement the `Clone` trait.
/// fn assoc_fn_args<T: Clone, U>(non_ref_arg: T, ref_arg: &U);
///
/// // Note that non-reference arguments should implement the `Clone` trait.
/// // But it's not required for `self`.
/// fn self_fn_args<T: Clone, U>(self, non_ref_arg: T, ref_arg: &U);
/// }
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {
/// # fn no_args();
/// # fn assoc_fn_args<T: Clone, U>(non_ref_arg: T, ref_arg: &U);
/// # fn self_fn_args<T: Clone, U>(self, non_ref_arg: T, ref_arg: &U);
/// # }
/// ```
///
/// </details>
///
/// ## Limitations
///
/// * Trait functions can't have a return type.
/// * There should be no associated types.
/// * There should be no associated constants.
/// * The functions' arguments can be only identifiers or wildcards.
///
/// ```compile_fail
/// #[fortuples::auto_impl]
/// trait Trait {
/// // OK
/// fn ident_and_wildcard(arg: i32, _: char);
///
/// // NOT OK
/// fn tuple_destruct((a, b): (i32, char));
/// }
/// ```
///
/// * There should be no macro calls inside the trait itself.
///
/// ```compile_fail
/// macro_rules! some_macro {
/// () => {};
/// }
///
/// #[fortuples::auto_impl]
/// trait Trait {
/// some_macro!();
/// }
/// ```
///
/// However, macro calls are allowed inside the default implementations.
/// ```
/// macro_rules! some_macro {
/// () => {};
/// }
///
/// #[fortuples::auto_impl]
/// trait Trait {
/// fn test() {
/// some_macro!();
/// }
/// }
/// ```
///
/// ## Settings
///
/// #### min_size
/// `#[tuples::min_size]` sets the length of the first tuple. By default, it equals `0`.
///
/// ```
/// #[fortuples::auto_impl]
/// #[tuples::min_size(2)]
/// # #[tuples::debug_expand(path = "doc/expand/auto_impl_min_size.rs")]
/// trait Trait {}
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>
///
/// #### max_size
/// `#[tuples::max_size]` sets the length of the last tuple. By default, it equals `16`.
///
/// ```
/// #[fortuples::auto_impl]
/// #[tuples::max_size(4)]
/// # #[tuples::debug_expand(path = "doc/expand/auto_impl_max_size.rs")]
/// trait Trait {}
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>
///
/// #### refs_tuple
/// `#[tuples::refs_tuple]` adds references to each member type inside the current tuple.
///
/// ###### Immutable refs
///
/// ```
/// #[fortuples::auto_impl]
/// #[tuples::refs_tuple]
/// # #[tuples::debug_expand(path = "doc/expand/auto_impl_refs_tuple.rs")]
/// trait Trait {}
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>
///
/// ###### Mutable refs
///
/// ```
/// #[fortuples::auto_impl]
/// #[tuples::refs_tuple(mut)]
/// # #[tuples::debug_expand(path = "doc/expand/auto_impl_refs_tuple_mut.rs")]
/// trait Trait {}
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>
///
/// #### debug_expand
/// `#[tuples::debug_expand]` will print the macro expansion.
///
/// The expansion can be printed either to stdout or a file.
/// * `#[tuples::debug_expand]` prints to stdout.
/// * `#[tuples::debug_expand(path = "<filepath>")]` prints to the file specified by the `<filepath>`.
///
/// All the macro expansions provided in this documentation were obtained using this setting.
///
/// >_Note: the `#[tuples::debug_expand]` prints the macro expansion only if the `debug` feature is enabled._
///
/// ```
/// #[fortuples::auto_impl]
/// #[tuples::debug_expand(path = "doc/expand/auto_impl_debug_expand.rs")]
/// trait Trait {}
/// ```
///
/// <details>
/// <summary>Show the macro expansion</summary>
///
/// ```
/// # trait Trait {}
/// ```
///
/// </details>