Crates.io | cfg-or-panic |
lib.rs | cfg-or-panic |
version | 0.2.1 |
source | src |
created_at | 2023-08-30 10:47:26.74779 |
updated_at | 2024-05-21 06:03:48.365488 |
description | Replace function bodies with `unimplemented!()` when condition is not met. |
homepage | |
repository | https://github.com/BugenZhao/cfg-or-panic |
max_upload_size | |
id | 958881 |
size | 21,326 |
#[cfg_or_panic(..)]
Keep the function body under #[cfg(..)]
, or replace it with unimplemented!()
under #[cfg(not(..))]
.
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);
}