I was using if cfg!()
to simulate this type of stuff:
pub fn something(&self) {
#[cfg(feature = "feature1")]
{
}
#[cfg(not(feature = "feature1"))]
{
unimplemented!()
}
}
until I realized that if cfg!()
does not hide the calls inside its {}
, it's just a common if
that has the true
value hardcoded so on runtime it always picks the right one.
I could get away with doing as above, but what if I have 3 implementations per feature? What about 4? Then I'd have to put lots of #[cfg(and(not(feature = "feature1"), not(feature="feature2")))]
and etc.
What would be the best solution in this case?