From 38df15805ba5be78d70c515f1d585ee6be95e13b Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 10 Aug 2025 16:17:26 -0700 Subject: cfg_select: Support unbraced expressions When operating on expressions, `cfg_select!` can now handle expressions without braces. (It still requires braces for other things, such as items.) Expand the test coverage and documentation accordingly. --- library/core/src/macros/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'library') diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index c59290a757b..db8b527d593 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -223,13 +223,14 @@ pub macro assert_matches { /// } /// ``` /// -/// The `cfg_select!` macro can also be used in expression position: +/// The `cfg_select!` macro can also be used in expression position, with or without braces on the +/// right-hand side: /// /// ``` /// #![feature(cfg_select)] /// /// let _some_string = cfg_select! { -/// unix => { "With great power comes great electricity bills" } +/// unix => "With great power comes great electricity bills", /// _ => { "Behind every successful diet is an unwatched pizza" } /// }; /// ``` -- cgit 1.4.1-3-g733a5