What if a library crate defines an enum
that has a variant that is feature-gated?
#[non_exhaustive]
enum Foo {
A,
B,
#[cfg(feature = "some-feature")]
Gated,
}
This is a naïve attempt to allow the enum Foo
to support the optional feature with the Gated
variant, while also allowing clients who do not need the feature to opt out of the costs associated with it (by disabling the crate feature some-feature
).
What are the potential dangers and/or costs associated with doing this? Are there any compelling reasons for avoiding this pattern?