Skip to content

Commit

Permalink
Merge pull request #1157 from cchiw/issue-77443-fix
Browse files Browse the repository at this point in the history
Documentation PR for cfg_panic
  • Loading branch information
ehuss authored Mar 15, 2022
2 parents 8e462e9 + 267f815 commit 0a2fe66
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/conditional-compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ production. For example, it controls the behavior of the standard library's
Set when the crate being compiled is being compiled with the `proc_macro`
[crate type].

### `panic`

Key-value option set depending on the panic strategy. Note that more values may be added in the future.

Example values:

* `"abort"`
* `"unwind"`

## Forms of conditional compilation

### The `cfg` attribute
Expand Down Expand Up @@ -253,6 +262,13 @@ fn on_32bit_unix() {
fn needs_not_foo() {
// ...
}

// This function is only included when the panic strategy is set to unwind
#[cfg(panic = "unwind")]
fn when_unwinding() {
// ...
}

```

The `cfg` attribute is allowed anywhere attributes are allowed.
Expand Down

0 comments on commit 0a2fe66

Please sign in to comment.