1use super::OrderByExpr;
2
3#[derive(Debug, Clone, PartialEq)]
18pub struct OrderBy {
19 pub exprs: Vec<OrderByExpr>,
21}
22
23impl OrderBy {
24 pub fn reverse(&mut self) {
26 for expr in &mut self.exprs {
27 expr.reverse();
28 }
29 }
30}
31
32impl From<OrderByExpr> for OrderBy {
33 fn from(value: OrderByExpr) -> Self {
34 Self { exprs: vec![value] }
35 }
36}
37
38macro_rules! impl_for_tuple {
39 ( $(($T:ident, $idx:tt)),+ ) => {
40 impl<$($T),+> From<($($T,)+)> for OrderBy
41 where
42 $($T: Into<OrderByExpr>,)+
43 {
44 fn from(src: ($($T,)+)) -> Self {
45 Self {
46 exprs: vec![$(src.$idx.into()),+],
47 }
48 }
49 }
50 };
51}
52
53impl_for_tuple!((T0, 0), (T1, 1));
54impl_for_tuple!((T0, 0), (T1, 1), (T2, 2));
55impl_for_tuple!((T0, 0), (T1, 1), (T2, 2), (T3, 3));
56impl_for_tuple!((T0, 0), (T1, 1), (T2, 2), (T3, 3), (T4, 4));
57impl_for_tuple!((T0, 0), (T1, 1), (T2, 2), (T3, 3), (T4, 4), (T5, 5));
58impl_for_tuple!(
59 (T0, 0),
60 (T1, 1),
61 (T2, 2),
62 (T3, 3),
63 (T4, 4),
64 (T5, 5),
65 (T6, 6)
66);
67impl_for_tuple!(
68 (T0, 0),
69 (T1, 1),
70 (T2, 2),
71 (T3, 3),
72 (T4, 4),
73 (T5, 5),
74 (T6, 6),
75 (T7, 7)
76);
77impl_for_tuple!(
78 (T0, 0),
79 (T1, 1),
80 (T2, 2),
81 (T3, 3),
82 (T4, 4),
83 (T5, 5),
84 (T6, 6),
85 (T7, 7),
86 (T8, 8)
87);
88impl_for_tuple!(
89 (T0, 0),
90 (T1, 1),
91 (T2, 2),
92 (T3, 3),
93 (T4, 4),
94 (T5, 5),
95 (T6, 6),
96 (T7, 7),
97 (T8, 8),
98 (T9, 9)
99);
100impl_for_tuple!(
101 (T0, 0),
102 (T1, 1),
103 (T2, 2),
104 (T3, 3),
105 (T4, 4),
106 (T5, 5),
107 (T6, 6),
108 (T7, 7),
109 (T8, 8),
110 (T9, 9),
111 (T10, 10)
112);
113impl_for_tuple!(
114 (T0, 0),
115 (T1, 1),
116 (T2, 2),
117 (T3, 3),
118 (T4, 4),
119 (T5, 5),
120 (T6, 6),
121 (T7, 7),
122 (T8, 8),
123 (T9, 9),
124 (T10, 10),
125 (T11, 11)
126);