Macros 查看宏输出
如何查看扩展的Rust宏的代码输出 例如,我有以下代码片段:Macros 查看宏输出,macros,rust,Macros,Rust,如何查看扩展的Rust宏的代码输出 例如,我有以下代码片段: macro_rules! five_times { ($x:expr) => (5 * $x); } fn main() { let a = five_times!(2 + 3); } 我想看到这样的东西: fn main() { let a = 5 * (2 + 3); } 使用nightly Rust时,可以对源文件使用以下命令: rustc --pretty expanded -Z unsta
macro_rules! five_times {
($x:expr) => (5 * $x);
}
fn main() {
let a = five_times!(2 + 3);
}
我想看到这样的东西:
fn main() {
let a = 5 * (2 + 3);
}
使用nightly Rust时,可以对源文件使用以下命令:
rustc --pretty expanded -Z unstable-options FILENAME.rs
这将打印以下输出:
macro_rules! five_times(( $ x : expr ) => ( 5 * $ x ) ;);
fn main() { let a = 5 * (2 + 3); }
使用nightly Rust时,可以对源文件使用以下命令:
rustc --pretty expanded -Z unstable-options FILENAME.rs
这将打印以下输出:
macro_rules! five_times(( $ x : expr ) => ( 5 * $ x ) ;);
fn main() { let a = 5 * (2 + 3); }