最佳答案
                                        
                                                                        
                                使用 C 语言的预处理器,
#if defined(NDEBUG)
// release build
#endif
#if defined(DEBUG)
// debug build
#endif
货物的粗略等价物是:
cargo build --release准备释放。cargo build调试。如何使用 Rust 的 #[cfg(...)]属性或 cfg!(...)宏来做类似的事情?
我知道 Rust 的预处理器不像 C 语言那样工作。我查了文档和 此页面列出了一些属性.(假设这个列表是全面的)
debug_assertions could be checked, but it may be misleading when used to check for the more general debugging case.
我不确定这个问题是否应该与货物有关。
