There are examples in my Rust project that apply only to specific functions .
I can ignore the main function with:
#[cfg(feature = "foo")]
fn main() {
But other function-dependent statements cause errors at startup cargo test. Therefore, I have to use several cfg attribute operators for functions and use instructions to disable code that depends on this function.
Is there a way to simply ignore the entire example file depending on the function configuration?
Also, since main is hidden without a function, it cargo testhas this error:
error: main function not found
So this is a bad decision.
source
share