Skip to content

Commit cb6dc8c

Browse files
add another several sentences to the macro docs
1 parent b16f33d commit cb6dc8c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/macros.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ macro_rules! cfg_if {
8282
/// Similar to [`cfg_if`](cfg_if), but accepts a list of expressions, and generates an internal
8383
/// closure to return each value.
8484
///
85+
/// The main reason this is necessary is because attaching `#[cfg(...)]` annotations to certain
86+
/// types of statements requires a nightly feature, or `cfg_if` would be enough on its own. This
87+
/// macro's restricted interface allows it to generate a closure as a circumlocution that is legal
88+
/// on stable rust.
89+
///
90+
/// Note that any `return` operation within the expressions provided to this macro will apply to the
91+
/// generated closure, not the enclosing scope--it cannot be used to interfere with external
92+
/// control flow.
93+
///
8594
/// The generated closure is non-[`const`](const@keyword), so cannot be used inside `const` methods.
8695
#[doc(hidden)]
8796
#[macro_export]

0 commit comments

Comments
 (0)