自定义
一些条件(如 target_os
)是由 rustc
隐式提供的,但自定义条件必须通过 --cfg
标志传递给 rustc
。
尝试运行这段代码,看看没有自定义 cfg
标志会发生什么。
使用自定义 cfg
标志:
$ rustc --cfg some_condition custom.rs && ./custom
condition met!
一些条件(如 target_os
)是由 rustc
隐式提供的,但自定义条件必须通过 --cfg
标志传递给 rustc
。
尝试运行这段代码,看看没有自定义 cfg
标志会发生什么。
使用自定义 cfg
标志:
$ rustc --cfg some_condition custom.rs && ./custom
condition met!