Skip to content

Commit 168229b

Browse files
committed
Re-export cfg_if macro from libstd and test
1 parent 881b592 commit 168229b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/libstd/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ pub use core::{assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert
327327
#[stable(feature = "rust1", since = "1.0.0")]
328328
pub use core::{unreachable, unimplemented, write, writeln, r#try, todo};
329329

330+
#[unstable(feature = "cfg_if", issue = "59442")]
331+
pub use core::cfg_if;
332+
333+
330334
#[allow(unused_imports)] // macros from `alloc` are not used on all platforms
331335
#[macro_use]
332336
extern crate alloc as alloc_crate;

src/libstd/tests/cfg_if.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub use std::cfg_if;
2+
3+
cfg_if! {
4+
if #[cfg(test)] {
5+
fn foo() -> bool { true }
6+
} else {
7+
fn foo() -> bool { false }
8+
}
9+
}
10+
11+
#[test]
12+
fn cfg_if_test {
13+
assert!(foo());
14+
}

0 commit comments

Comments
 (0)