rs_split_table/rdb/simple/row2tab/row2cp.rs
1//! Functions to create [`RowToTableName`] using copiable types.
2
3use crate::rdb::row2tab::row2tname_new;
4use crate::rdb::row2tab::RowToTableName;
5
6/// Creates a [`RowToTableName`] from functions.
7///
8/// ## Arguments
9/// - row2cp: Converts the row `R` to a copiable `C`.
10/// - cp2tab: Converts the copiable `C` to the name of the table.
11pub fn row2tname_row2cp_new<R, F, S, C>(row2cp: F, cp2tab: S) -> impl RowToTableName<Row = R>
12where
13 R: Send + Sync + 'static,
14 C: Copy,
15 F: Fn(&R) -> C + Sync + Send + 'static,
16 S: Fn(C) -> String + Sync + Send + 'static,
17{
18 row2tname_new(move |row: &R| {
19 let cp: C = row2cp(row);
20 let tab_name: String = cp2tab(cp);
21 Ok(tab_name)
22 })
23}