You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the TraitConfiguration struct describes a user-designated trait configuration wherein the user can decide which combination of traits are enabled/disabled for a given package. The way this struct is currently designed allows for an optional set of enabled traits, as well as a bool that describes the flag to enableAllTraits. Since there are distinct use cases depending on whether or not the enabled traits are nil, empty, or contains a list of traits, it makes more sense to treat this as an enum:
enumTraitConfiguration:Codable,Hashable{case enableAllTraits // when the enableAllTraits flag is set, since this will simply enable everything
case noConfiguration // when there isn't a configuration set, meaning that the default traits will be used
case noTraits // when there is a configuration set and the set of enabled traits is empty, which overrides the default traits
case traits(Set<String>) // when there is a configuration set and there is a set of traits present
}
Expected behavior
This will make the checks done on TraitConfiguration to be more ergonomic, as there would be a defined set of cases that are explicitly named and would omit redundant checks.
Actual behavior
The current use of TraitConfiguration can be a bit painful - there are plenty of condition checks involving repeated terms (i.e. if let enabledTraits = traitConfiguration.enabledTraits, traitConfiguration.enableAllTraits == false { ... } and other variations of this) that can be condensed for ease of use.
Steps to reproduce
No response
Swift Package Manager version/commit hash
No response
Swift & OS version (output of swift --version && uname -a)
No response
The text was updated successfully, but these errors were encountered:
Description
Currently, the
TraitConfiguration
struct describes a user-designated trait configuration wherein the user can decide which combination of traits are enabled/disabled for a given package. The way this struct is currently designed allows for an optional set of enabled traits, as well as abool
that describes the flag toenableAllTraits
. Since there are distinct use cases depending on whether or not the enabled traits arenil
, empty, or contains a list of traits, it makes more sense to treat this as an enum:Expected behavior
This will make the checks done on
TraitConfiguration
to be more ergonomic, as there would be a defined set of cases that are explicitly named and would omit redundant checks.Actual behavior
The current use of
TraitConfiguration
can be a bit painful - there are plenty of condition checks involving repeated terms (i.e.if let enabledTraits = traitConfiguration.enabledTraits, traitConfiguration.enableAllTraits == false { ... }
and other variations of this) that can be condensed for ease of use.Steps to reproduce
No response
Swift Package Manager version/commit hash
No response
Swift & OS version (output of
swift --version && uname -a
)No response
The text was updated successfully, but these errors were encountered: