3 unstable releases
0.2.1 | May 21, 2024 |
---|---|
0.2.0 | Sep 19, 2023 |
0.1.1 | Aug 30, 2023 |
0.1.0 |
|
#1875 in Rust patterns
3,496 downloads per month
8KB
131 lines
#[cfg_or_panic(..)]
Keep the function body under #[cfg(..)]
, or replace it with unimplemented!()
under #[cfg(not(..))]
.
Example
use cfg_or_panic::cfg_or_panic;
#[cfg_or_panic(feature = "foo")]
fn foo() -> i32 {
42
}
#[test]
#[cfg_attr(not(feature = "foo"), should_panic)]
fn test() {
assert_eq!(foo(), 42);
}
Dependencies
~230–670KB
~16K SLoC