-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Macros should have an operator type #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Might be better to call it |
+1, this is really useful and would avoid a lot of boilerplate especially in operator overloading on simple structs |
macro_rules! foo {
($oper:tt) => (10 $oper 20)
}
fn main() {
println!("{}", foo!(+));
println!("{}", foo!(*));
} It won't reject non-operators though. |
That doesn't work in all places an operator can exist, unfortunately, since eg macro_rules! example {
($lhs:expr $op:tt $rhs:expr) => {}
}
|
|
oh wow, ok. Probably a separate rfc for that, in that case |
there is no way to "fix" this because |
Thursday Aug 29, 2013 at 11:55 GMT
For earlier discussion, see rust-lang/rust#8853
This issue was labelled with: A-syntaxext, I-enhancement in the Rust repository
AFAIK there is currently no way to quote an operator such as
+
or/
, and this would be useful to reduce code duplication.Something like:
The text was updated successfully, but these errors were encountered: