Custom

Some conditionals like target_os are implicitly provided by rustc, but custom conditionals must be passed to rustc using the --cfg flag.

1. #[cfg(some_condition)]
2. fn conditional_function() {
3. println!("condition met!");
4. }

6. fn main() {
7. conditional_function();
8. }

Try to run this to see what happens without the custom cfg flag.

With the custom cfg flag:

1. $ rustc --cfg some_condition custom.rs && ./custom
2. condition met!