Skip to content

Commit 0229b44

Browse files
update cfg_select! documentation
and make internal terminology consistent Co-authored-by: Travis Cross <[email protected]>
1 parent 9d16539 commit 0229b44

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

core/src/macros/mod.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,14 @@ pub macro assert_matches {
196196
},
197197
}
198198

199-
/// A macro for defining `#[cfg]` match-like statements.
199+
/// Selects code at compile-time based on `cfg` predicates.
200200
///
201-
/// It is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of
202-
/// `#[cfg]` cases, emitting the implementation which matches first.
201+
/// This macro evaluates, at compile-time, a series of `cfg` predicates,
202+
/// selects the first that is true, and emits the code guarded by that
203+
/// predicate. The code guarded by other predicates is not emitted.
203204
///
204-
/// This allows you to conveniently provide a long list `#[cfg]`'d blocks of code
205-
/// without having to rewrite each clause multiple times.
206-
///
207-
/// Trailing `_` wildcard match arms are **optional** and they indicate a fallback branch when
208-
/// all previous declarations do not evaluate to true.
205+
/// An optional trailing `_` wildcard can be used to specify a fallback. If
206+
/// none of the predicates are true, a [`compile_error`] is emitted.
209207
///
210208
/// # Example
211209
///
@@ -225,7 +223,7 @@ pub macro assert_matches {
225223
/// }
226224
/// ```
227225
///
228-
/// If desired, it is possible to return expressions through the use of surrounding braces:
226+
/// The `cfg_select!` macro can also be used in expression position:
229227
///
230228
/// ```
231229
/// #![feature(cfg_select)]

0 commit comments

Comments
 (0)