forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#71828 - Dylan-DPC:rollup-qf5h2w5, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#71165 (`slice::fill`: use `T` instead of generic arg) - rust-lang#71314 (Implement RFC 2523, `#[cfg(version(..))]`) - rust-lang#71542 (Implement `confusable_idents` lint.) - rust-lang#71806 (typo) - rust-lang#71813 (Decode qualifs for associated const defaults) Failed merges: r? @ghost
- Loading branch information
Showing
27 changed files
with
573 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/doc/unstable-book/src/language-features/cfg-version.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
// ... | ||
} | ||
} | ||
``` |
Oops, something went wrong.