about summary refs log tree commit diff
path: root/src/doc/reference.md
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc/reference.md')
-rw-r--r--src/doc/reference.md18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md
index c34a136a68e..cf9504736eb 100644
--- a/src/doc/reference.md
+++ b/src/doc/reference.md
@@ -2066,26 +2066,28 @@ fn macos_only() {
 }
 
 // This function is only included when either foo or bar is defined
-#[cfg(foo)]
-#[cfg(bar)]
+#[cfg(any(foo, bar))]
 fn needs_foo_or_bar() {
   // ...
 }
 
 // This function is only included when compiling for a unixish OS with a 32-bit
 // architecture
-#[cfg(unix, target_word_size = "32")]
+#[cfg(all(unix, target_word_size = "32"))]
 fn on_32bit_unix() {
   // ...
 }
+
+// This function is only included when foo is not defined
+#[cfg(not(foo))]
+fn needs_not_foo() {
+  // ...
+}
 ```
 
 This illustrates some conditional compilation can be achieved using the
-`#[cfg(...)]` attribute. Note that `#[cfg(foo, bar)]` is a condition that needs
-both `foo` and `bar` to be defined while `#[cfg(foo)] #[cfg(bar)]` only needs
-one of `foo` and `bar` to be defined (this resembles in the disjunctive normal
-form). Additionally, one can reverse a condition by enclosing it in a
-`not(...)`, like e. g. `#[cfg(not(target_os = "win32"))]`.
+`#[cfg(...)]` attribute. `any`, `all` and `not` can be used to assemble
+arbitrarily complex configurations through nesting.
 
 The following configurations must be defined by the implementation: