rust-lang / cfg-if

A if/elif-like macro for Rust #[cfg] statements
Apache License 2.0
557 stars 40 forks source link

unexpected behavior inside struct, for feature-gated arguments #55

Open thor314 opened 2 years ago

thor314 commented 2 years ago

Attempting the following:

pub(crate) struct Args {
    cfg_if! {
        if #[cfg(feature = "my_feat")] {
            some_feature_gated_arg: u8,
            some_other_feature_gated_arg: u8,
        } else {}
    }
    // ...
}

causes compile time errors. This would have been helpful to note in the Readme/docs.