Skip to main content

rs_split_table/rdb/simple/row2tab/
row2num.rs

1//! Functions to create [`RowToTableName`].
2
3use crate::rdb::row2tab::RowToTableName;
4
5use super::row2cp::row2tname_row2cp_new;
6
7macro_rules! row2tname_row2num {
8    ($numtyp: ty, $fname: ident) => {
9        /// Creates a [`RowToTableName`] which uses a number to create the name.
10        ///
11        /// ## Arguments
12        /// - row2num: Converts the row to the number.
13        /// - num2tab: Creates the name of the table from the number.
14        pub fn $fname<R, F, S>(row2num: F, num2tab: S) -> impl RowToTableName<Row = R>
15        where
16            R: Send + Sync + 'static,
17            F: Fn(&R) -> $numtyp + Sync + Send + 'static,
18            S: Fn($numtyp) -> String + Sync + Send + 'static,
19        {
20            row2tname_row2cp_new(row2num, num2tab)
21        }
22    };
23}
24
25row2tname_row2num!(i128, row2tname_row2num_new128i);
26row2tname_row2num!(i64, row2tname_row2num_new64i);
27row2tname_row2num!(i32, row2tname_row2num_new32i);
28row2tname_row2num!(i16, row2tname_row2num_new16i);
29row2tname_row2num!(i8, row2tname_row2num_new8i);
30
31row2tname_row2num!(u128, row2tname_row2num_new128u);
32row2tname_row2num!(u64, row2tname_row2num_new64u);
33row2tname_row2num!(u32, row2tname_row2num_new32u);
34row2tname_row2num!(u16, row2tname_row2num_new16u);
35row2tname_row2num!(u8, row2tname_row2num_new8u);