add code
This commit is contained in:
14
13.Attributes/13.4 Custom/custom.rs
Normal file
14
13.Attributes/13.4 Custom/custom.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
//! cfg 还支持自定义属性值
|
||||
//! 通过 `rustc --cfg custom` 传递额外的值
|
||||
//!
|
||||
|
||||
// 这个属性就是外部传递的
|
||||
// rustc --cfg some_condition custom.rs && ./custom
|
||||
#[cfg(some_condition)]
|
||||
fn conditional_function() {
|
||||
println!("condition met!");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
conditional_function();
|
||||
}
|
||||
Reference in New Issue
Block a user