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
//! [tuplities](https://github.com/lucacappelletti94/tuplities) suite crate providing the `TupleRow` and `TupleRowMut` traits.
use TupleLen;
use TupleMut;
use TupleRef;
/// A trait for indexing rows in tuples of tuples.
///
/// This trait allows accessing elements at a specific index across all tuples in a tuple of tuples.
/// For a tuple of tuples like `((A, B), (C, D))`, `TupleRow<U0>` would return `(&A, &C)` and `TupleRow<U1>` would return `(&B, &D)`.
///
/// Each inner tuple must implement `TupleIndex<Idx>`, and the returned row tuple implements `TupleRef`.
///
/// # Examples
///
/// ```
/// use tuplities_row::TupleRow;
/// use typenum::U0;
///
/// let matrix = ((1, 2), (3, 4), (5, 6));
/// let first_row = TupleRow::<U0>::tuple_row(&matrix);
/// assert_eq!(first_row, (&1, &3, &5));
/// ```
///
/// Part of the [`tuplities`](https://docs.rs/tuplities/latest/tuplities/) crate.
/// A trait for mutable indexing rows in tuples of tuples.
///
/// This trait allows mutable access to elements at a specific index across all tuples in a tuple of tuples.
/// For a tuple of tuples like `((A, B), (C, D))`, `TupleRowMut<U0>` would return `(&mut A, &mut C)` and `TupleRowMut<U1>` would return `(&mut B, &mut D)`.
///
/// Each inner tuple must implement `TupleIndexMut<Idx>`, and the returned row tuple implements `TupleMut`.
///
/// # Examples
///
/// ```
/// use tuplities_row::TupleRowMut;
/// use typenum::U0;
///
/// let mut matrix = ((1, 2), (3, 4), (5, 6));
/// let first_row = TupleRowMut::<U0>::tuple_row_mut(&mut matrix);
/// *first_row.0 = 10;
/// *first_row.1 = 30;
/// *first_row.2 = 50;
/// assert_eq!(matrix, ((10, 2), (30, 4), (50, 6)));
/// ```
///
/// Part of the [`tuplities`](https://docs.rs/tuplities/latest/tuplities/) crate.
/// A convenience trait for accessing the first row (index 0) in tuples of tuples.
///
/// This trait is automatically implemented for any tuple of tuples where each inner tuple implements `TupleRefFront`.
///
/// # Examples
///
/// ```
/// use tuplities_row::FirstTupleRow;
///
/// let matrix = ((1, 2), (3, 4), (5, 6));
/// let first_row = matrix.first_tuple_row();
/// assert_eq!(first_row, (&1, &3, &5));
/// ```
///
/// Part of the [`tuplities`](https://docs.rs/tuplities/latest/tuplities/) crate.
/// A convenience trait for accessing the last row in tuples of tuples.
///
/// This trait is automatically implemented for tuples of tuples where the implementation
/// depends on the length of the inner tuples. It provides access to the last element
/// of each inner tuple.
///
/// # Examples
///
/// ```
/// use tuplities_row::LastTupleRow;
///
/// let matrix = ((1, 2, 3), (4, 5, 6), (7, 8, 9));
/// let last_row = matrix.last_tuple_row();
/// assert_eq!(last_row, (&3, &6, &9));
/// ```
///
/// Part of the [`tuplities`](https://docs.rs/tuplities/latest/tuplities/) crate.