34 lines
608 B
Rust
34 lines
608 B
Rust
/// A dynamic query structure.
|
|
pub trait DynamicQuery {
|
|
type Definition;
|
|
|
|
fn filter_ref(&mut self, def: &Self::Definition);
|
|
|
|
fn filter(mut self, def: &Self::Definition) -> Self
|
|
where
|
|
Self: Sized,
|
|
{
|
|
self.filter_ref(def);
|
|
self
|
|
}
|
|
}
|
|
|
|
mod macros;
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
// just tests that the macro compiles
|
|
crate::query_def! {
|
|
Foo(FooDef) {
|
|
bar: 'dyn (Bar),
|
|
baz: (bool),
|
|
bars: 'vec (Bar),
|
|
bars_by_bazs: 'map (bool, Bar),
|
|
}
|
|
|
|
Bar(BarDef) {
|
|
baz: (bool),
|
|
}
|
|
}
|
|
}
|