Skip to main content


🦀​ Rust 🦀​ people, is there a way to use conditional compilation in the match parts of a declarative macro? Other than duplicating the whole macro definition.

Basically something like

macro_rules! foo(<br>    ($x:expr) => { {<br>        println!("{}", $x);<br>    }};<br>    #[cfg(target_os = "linux")]<br>    ($x:expr, $y:expr) => { {<br>        println!("{} {}", $x, $y);<br>    }};<br>);<br>

This currently fails compiling: play.rust-lang.org/?version=st…

#Rust #RustLang