Skip to content

Just like a create-root level `#![cfg(...)]` macro, but injects a dummy `fn main` when the predicate is `false`

Notifications You must be signed in to change notification settings

MOZGIII/cfg-fake-main

Repository files navigation

cfg-fake-main

Requirements

Installation

cargo add fake-main

Usage

Assuming you have defined a skip feature at Cargo.toml:

#![feature(prelude_import)] // needed, idk why
#![feature(custom_inner_attributes)] // needed to use this macro cause it is a nightly feature
#![::fake_main::cfg_(not(feature = "skip"))]

/// The real main fn.
fn main() {
    println!("Real fn main");
}
$ cargo run

...

Real fn main
$ cargo run --features skip

...

thread 'main' panicked at .../src/main.rs:3:1:
not implemented: not(feature = "skip")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

About

Just like a create-root level `#![cfg(...)]` macro, but injects a dummy `fn main` when the predicate is `false`

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published