pub mod rusqlite_struct;
pub use rusqlite_struct::RusqliteStruct;
pub mod rusqlite_struct_helper;
struct Test {
id: i32,
test: String
}
impl RusqliteStruct for Test {
fn struct_name() -> &'static str {
"Test"
}
fn field_names() -> &'static [&'static str] {
&["id", "test"]
}
}
#[test]
pub fn test() {
let to_execute = format!(
"INSERT INTO {} ({}) VALUES ({})",
Test::struct_name(),
format!("{}", Test::field_names().join(",")),
format!("{}", Test::field_names().iter().map(|s| format!(":{}", s)).collect::<Vec<String>>().join(","))
);
assert_eq!(to_execute, "INSERT INTO Test (id,test) VALUES (:id,:test)")
}