Show details in cfg version unstable book
This commit is contained in:
parent
f24ce9b014
commit
b5ca329616
|
@ -7,19 +7,20 @@ The tracking issue for this feature is: [#64796]
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
The `cfg_version` feature makes it possible to execute different code
|
The `cfg_version` feature makes it possible to execute different code
|
||||||
depending on the compiler version.
|
depending on the compiler version. It will return true if the compiler
|
||||||
|
version is greater than or equal to the specified version.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#![feature(cfg_version)]
|
#![feature(cfg_version)]
|
||||||
|
|
||||||
#[cfg(version("1.42"))]
|
#[cfg(version("1.42"))] // 1.42 and above
|
||||||
fn a() {
|
fn a() {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(version("1.42")))]
|
#[cfg(not(version("1.42")))] // 1.41 and below
|
||||||
fn a() {
|
fn a() {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue