假设我有一个仅在启用glob
时才依赖于该板条箱的板条箱。#[cfg(feature = "glob")]
此外,默认情况下禁用此功能。如何glob
默认跳过下载和编译 crate?
# Cargo.toml
...
[features]
default = []
[dependencies]
glob = "0.2"
...
和源代码:
# lib.rs
.. several uses
#[cfg(feature = "glob")]
extern crate glob;
... a lot of code that doesn't use glob crate.
#[cfg(feature = "glob")]
impl Foo for Bar {
// only this code uses glob crate
}