Skip to content

Commit aa2bfc9

Browse files
authored
Merge pull request #1474 from cspanda/update-cfg-docs
Add note about distinction between attribute and macro cfg from std docs into rust-by-example docs
2 parents 4b5fed6 + 3e833e8 commit aa2bfc9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/attribute/cfg.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ While the former enables conditional compilation, the latter conditionally
99
evaluates to `true` or `false` literals allowing for checks at run-time. Both
1010
utilize identical argument syntax.
1111

12+
`cfg!`, unlike `#[cfg]`, does not remove any code and only evaluates to true or false. For example, all blocks in an if/else expression need to be valid when `cfg!` is used for the condition, regardless of what `cfg!` is evaluating.
13+
1214
```rust,editable
1315
// This function only gets compiled if the target OS is linux
1416
#[cfg(target_os = "linux")]

0 commit comments

Comments
 (0)