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
//! A trait for getting the length of tuples at compile time.
//!
//! This crate provides the `TupleLen` trait, which allows getting the length
//! of a tuple as a compile-time `typenum::Unsigned` type.
/// A trait for getting the compile-time length of a tuple.
///
/// This trait provides the length of a tuple as an associated type `Len`
/// that implements `typenum::Unsigned`.
///
/// Part of the [`tuplities`](https://docs.rs/tuplities/latest/tuplities/) crate.
/// A marker trait for empty tuples (size 0).
///
/// This trait is implemented for the unit type `()` and can be used
/// for type-level programming to identify empty tuples.
///
/// # Examples
///
/// ```
/// use tuplities_len::{UnitTuple, TupleLen};
/// use typenum::U0;
///
/// fn is_empty<T: UnitTuple>(_tuple: T) {
/// // This function only accepts empty tuples
/// }
///
/// is_empty(()); // This works
/// // is_empty((1,)); // This would not compile
/// ```
///
/// Part of the [`tuplities`](https://docs.rs/tuplities/latest/tuplities/) crate.
/// A marker trait for single-element tuples (size 1).
///
/// This trait is implemented for single-element tuples `(T,)` and can be used
/// for type-level programming to identify single-element tuples.
///
/// # Examples
///
/// ```
/// use tuplities_len::{SingletonTuple, TupleLen};
/// use typenum::U1;
///
/// fn is_single<T: SingletonTuple>(_tuple: T) {
/// // This function only accepts single-element tuples
/// }
///
/// is_single((42,)); // This works
/// // is_single((1, 2)); // This would not compile
/// // is_single(()); // This would not compile
/// ```
///
/// Part of the [`tuplities`](https://docs.rs/tuplities/latest/tuplities/) crate.
/// A marker trait for two-element tuples (size 2).
///
/// This trait is implemented for two-element tuples `(T1, T2)` and can be used
/// for type-level programming to identify two-element tuples.
///
/// # Examples
///
/// ```rust
/// use tuplities_len::{PairTuple, TupleLen};
/// use typenum::U2;
/// fn is_pair<T: PairTuple>(_tuple: T) {
/// // This function only accepts two-element tuples
/// }
/// is_pair((1, 2)); // This works
/// // is_pair((42,)); // This would not compile
/// // is_pair(()); // This would not compile
/// ```
///