memtable-macros 0.2.0

Macro library that provides ability to derive typed tables and generate tables compile-time.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::{utils, TableColumn};
use syn::{parse_quote, ItemConst};

pub struct Args<'a> {
    pub columns: &'a [&'a TableColumn],
}

pub fn make(args: Args) -> ItemConst {
    let Args { columns } = args;

    let column_names = utils::make_column_names(columns, ToString::to_string);

    parse_quote! {
        /// Represents the names of the columns associated with this type of table
        const COLUMN_NAMES: &'static [&'static ::core::primitive::str] = &[#(#column_names),*];
    }
}