Skip to content

Commit

Permalink
Rollup merge of rust-lang#135625 - c410-f3r:cfg-match-foo-bar-baz, r=…
Browse files Browse the repository at this point in the history
…tgross35,jhpratt

[cfg_match] Document the use of expressions.

cc rust-lang#115585

Adds documentation to this new feature introduced in rust-lang#133720.
  • Loading branch information
jieyouxu authored Jan 21, 2025
2 parents 047e679 + 587b9c6 commit b4e2fb5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,17 @@ pub macro cfg_match {
/// }
/// }
/// ```
///
/// If desired, it is possible to return expressions through the use of surrounding braces:
///
/// ```
/// #![feature(cfg_match)]
///
/// let _some_string = cfg_match! {{
/// unix => { "With great power comes great electricity bills" },
/// _ => { "Behind every successful diet is an unwatched pizza" },
/// }};
/// ```
#[cfg(not(bootstrap))]
#[unstable(feature = "cfg_match", issue = "115585")]
#[rustc_diagnostic_item = "cfg_match"]
Expand Down

0 comments on commit b4e2fb5

Please sign in to comment.