Pre-RFC: Cargo mutually exclusive features

Perhaps you're referring to something different from the use case I described, but the one I gave was more along the lines of:

Given features x, y, and z:

  • have x override y and z if either or both are activated
  • have y override z if both are activated (but x is not)

i.e. a declarative conflict-free approach to selecting a "winning" feature from a set of mutually exclusive ones. Another way of thinking about it is assigning priorities to conflicting features, and picking the highest priority feature if all of them are activated.

However as far as I can tell from this pre-RFC, the described mechanism has inherent conflicts rather than a way to resolve activation of multiple mutually exclusive features, particularly based on this part:

Now it validates:

  • that the number of features providing a capability less then 2
  • that for each required capability (for package and feature) the number of features is exactly 1

It also seems like you could update the RFC to introduce conflict resolution (if it's already in there, I missed it, mea culpa), perhaps by restructuring the provides attribute into something like a providers attribute which contains an ordered list by preference. Just spitballing here, based on your previous example:

[features]
json_backend = { providers = ["json_foo", "json_bar"] }