-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
if_test!() macro #8130
Comments
It seems like this might be useful as a general if_cfg!(test {
...
} else {
....
})
if_cfg!(target_word_size="64" { } else { })
if_cfg!(not(test) { ... }) |
Processing the cfgs before doing macro expansion makes this a bit harder, but how about something like this?:
|
@huonw points out that |
... and also that the exsting "debug!" macro should cover this issue's request. @bblum , do you think this issue should not be closed? |
@jbclements , Until something more pretty is added, I worked around this with:
… and using |
I just opened #8188 which implements if cfg!(test) {
assert!(something_expensive());
} Is this an appropriate solution? |
@huonw looks good, thanks! |
Yeah that's actually better than i was hoping for. Brilliant. |
Often I find myself writing code such as:
Sometimes this is logic that is not just an assert, in the case of
rt::comm::block_on()
. I wish for a macro so this could be done more concisely without needing to define clunky new function items.The text was updated successfully, but these errors were encountered: