-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Macros should have an operator type #8853
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
This seems in the same vein as #5748 I believe all the operators map to functions in built in traits, so you can probably work around this right now by switching to the method version. |
@metajack The problem with the methods is that they accept different types, for example: fn main() {
let x = ~"foo";
let y = ~"bar";
println(x.add(y));
}
/* z.rs:4:15: 4:16 error: mismatched types: expected `&&str` but found `~str` (expected &-ptr but found ~str)
z.rs:4 println(x.add(y));
^
*/ |
This can be worked around using the " #![feature(macro_rules)]
macro_rules! expr {
($e:expr) => {
$e
}
}
macro_rules! foo(
($op:tt) => {
expr!(10i $op 20i)
}
)
fn main() {
println!("{}", foo!(+));
println!("{}", foo!(*));
} @nick29581 Should this be moved to rust-lang/rfcs? I recall reading somewhere that all the changes to the macro system now require an RFC. (Found it) |
This issue has been moved to the RFCs repo: rust-lang/rfcs#426 |
feat(fix): ignore `todo!` and `unimplemented!` in `if_same_then_else` close: rust-lang#8836 take over: rust-lang#8853 This PR adds check `todo!` and `unimplemented!` in if_same_then_else. ( I thought `unimplemented` should not be checked as well as todo!.) Thank you in advance. changelog: ignore todo! and unimplemented! in if_same_then_else r? `@Jarcho`
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: