If the comparison operator can return a custom type, then when I perform comparison operations, I can record which calculations the user has performed and generate SQL correctly. But the reality is that comparative operations can only return boolean types. This poses a challenge to implementation.
I have to use macros to achieve approximation function, which not only destroys intelligent syntax prompts, but also reduces compilation speed, and the biggest problem is that the syntax is no longer concise
If you want custom syntax in Rust, macros should be the way to go.
Rust Analyzer can see through declarative macros, so if the syntax is expr-shaped and the macro emits the input as an unused closure, you'll still get autocompletion hints.
Using procedural macros definitely increases compilation time. That is unfortunate.
I'm not sure what you mean by "not concise", but you can limit the scope of the macro to the function call, which looks OK to me:
let ret: Vec<_> = conn.Select::<UserModel>().Where(expr!(p.age < 18)).ToArray();
Eventually we might get postfix macros, which would enable
let ret: Vec<_> = conn.Select::<UserModel>().Where!(p.age < 18).ToArray();