cfg-or-panic

Crates.iocfg-or-panic
lib.rscfg-or-panic
version0.2.1
sourcesrc
created_at2023-08-30 10:47:26.74779
updated_at2024-05-21 06:03:48.365488
descriptionReplace function bodies with `unimplemented!()` when condition is not met.
homepage
repositoryhttps://github.com/BugenZhao/cfg-or-panic
max_upload_size
id958881
size21,326
Bugen Zhao (BugenZhao)

documentation

README

#[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);
}
Commit count: 11

cargo fmt