I started to write some simple ORM for test purposes and i’m very interested in ability to make some dynamic code generation that could replace Ruby’s method_missing
.
Pseudo-code to illustrate the idea:
impl UserModel {
pub fn macro_method (find_by, $($field_name:ident)_and_+) (&self, $($field_value:expr),+) -> SelectQuery {
self.select_all().where_(
$(
self.$field_name().is($field_value),
)
)
}
}
let query = user_model.find_by_id!(100u);
let query = user_model.find_by_first_name_and_last_name!("Luke", "Skywalker");
What do you think about that? I you not interested please close this issue and never mind.