blob: 182d33654c5a535b7a0d0959998b36ea0321c53b [file] [log] [blame] [view]
# Custom
Some conditionals like `target_os` are implicitly provided by `rustc`, but
custom conditionals must be passed to `rustc` using the `--cfg` flag.
```rust,editable,ignore,mdbook-runnable
#[cfg(some_condition)]
fn conditional_function() {
println!("condition met!");
}
fn main() {
conditional_function();
}
```
Try to run this to see what happens without the custom `cfg` flag.
With the custom `cfg` flag:
```shell
$ rustc --cfg some_condition custom.rs && ./custom
condition met!
```