about summary refs log tree commit diff
path: root/src/doc/unstable-book
diff options
context:
space:
mode:
authormibac138 <5672750+mibac138@users.noreply.github.com>2020-04-19 10:47:55 +0200
committermibac138 <5672750+mibac138@users.noreply.github.com>2020-05-03 02:42:07 +0200
commit90aa62a1bf00c555abc834a21e84d9e7e20dcf86 (patch)
treeaf38c569715072b4a34fc133a07c276365a0a446 /src/doc/unstable-book
parentf05a5240440b3eaef1684a7965860fab40301947 (diff)
downloadrust-90aa62a1bf00c555abc834a21e84d9e7e20dcf86.tar.gz
rust-90aa62a1bf00c555abc834a21e84d9e7e20dcf86.zip
Implement RFC 2523, `#[cfg(version(..))]`
Diffstat (limited to 'src/doc/unstable-book')
-rw-r--r--src/doc/unstable-book/src/language-features/cfg-version.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/cfg-version.md b/src/doc/unstable-book/src/language-features/cfg-version.md
new file mode 100644
index 00000000000..2b1e50835b7
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/cfg-version.md
@@ -0,0 +1,34 @@
+# `cfg_version`
+
+The tracking issue for this feature is: [#64796]
+
+[#64796]: https://github.com/rust-lang/rust/issues/64796
+
+------------------------
+
+The `cfg_version` feature makes it possible to execute different code
+depending on the compiler version.
+
+## Examples
+
+```rust
+#![feature(cfg_version)]
+
+#[cfg(version("1.42"))]
+fn a() {
+    // ...
+}
+
+#[cfg(not(version("1.42")))]
+fn a() {
+    // ...
+}
+
+fn b() {
+    if cfg!(version("1.42")) {
+        // ...
+    } else {
+        // ...
+    }
+}
+```