use super::OrderByExpr;
#[derive(Debug, Clone, PartialEq)]
pub struct OrderBy {
pub exprs: Vec<OrderByExpr>,
}
impl OrderBy {
pub fn reverse(&mut self) {
for expr in &mut self.exprs {
expr.reverse();
}
}
}
impl From<OrderByExpr> for OrderBy {
fn from(value: OrderByExpr) -> Self {
Self { exprs: vec![value] }
}
}
macro_rules! impl_for_tuple {
( $(($T:ident, $idx:tt)),+ ) => {
impl<$($T),+> From<($($T,)+)> for OrderBy
where
$($T: Into<OrderByExpr>,)+
{
fn from(src: ($($T,)+)) -> Self {
Self {
exprs: vec![$(src.$idx.into()),+],
}
}
}
};
}
impl_for_tuple!((T0, 0), (T1, 1));
impl_for_tuple!((T0, 0), (T1, 1), (T2, 2));
impl_for_tuple!((T0, 0), (T1, 1), (T2, 2), (T3, 3));
impl_for_tuple!((T0, 0), (T1, 1), (T2, 2), (T3, 3), (T4, 4));
impl_for_tuple!((T0, 0), (T1, 1), (T2, 2), (T3, 3), (T4, 4), (T5, 5));
impl_for_tuple!(
(T0, 0),
(T1, 1),
(T2, 2),
(T3, 3),
(T4, 4),
(T5, 5),
(T6, 6)
);
impl_for_tuple!(
(T0, 0),
(T1, 1),
(T2, 2),
(T3, 3),
(T4, 4),
(T5, 5),
(T6, 6),
(T7, 7)
);
impl_for_tuple!(
(T0, 0),
(T1, 1),
(T2, 2),
(T3, 3),
(T4, 4),
(T5, 5),
(T6, 6),
(T7, 7),
(T8, 8)
);
impl_for_tuple!(
(T0, 0),
(T1, 1),
(T2, 2),
(T3, 3),
(T4, 4),
(T5, 5),
(T6, 6),
(T7, 7),
(T8, 8),
(T9, 9)
);
impl_for_tuple!(
(T0, 0),
(T1, 1),
(T2, 2),
(T3, 3),
(T4, 4),
(T5, 5),
(T6, 6),
(T7, 7),
(T8, 8),
(T9, 9),
(T10, 10)
);
impl_for_tuple!(
(T0, 0),
(T1, 1),
(T2, 2),
(T3, 3),
(T4, 4),
(T5, 5),
(T6, 6),
(T7, 7),
(T8, 8),
(T9, 9),
(T10, 10),
(T11, 11)
);